diff --git a/CHANGELOG.md b/CHANGELOG.md index 56b09a43..ed106ad5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,9 +20,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Moved tests to a separate disk (tests.d64). - gfx: Renamed ERASE to PEN. - #> (the pictured numeric output string buffer) now uses its own buffer chopped from the end of PAD. - - CHAR, HEADER and other parsing words no longer do REFILL on missing text. + - CHAR no longer does REFILL on missing text. - EVALUATE now accepts multi-line strings. - ( refills to accept multi-line comments when parsing EVALUATE strings. + - Defining words based on HEADER now abort with an error on missing text. ### Removed - GETC, 100/, INTERPRET, ;CODE (replace with: RTS, END-CODE) ### Fixed diff --git a/asm/compiler.asm b/asm/compiler.asm index 4eba8d3e..61c8f866 100644 --- a/asm/compiler.asm +++ b/asm/compiler.asm @@ -135,19 +135,26 @@ COLON jmp RBRAC ; enter compile mode - -; --- HEADER ( name -- ) +BACKLINK "header", 6 -HEADER +HEADER ; ( "name" -- ) inc last_word_no_tail_call_elimination - ; update dictionary - + ; Parse, get [W2]name-addr and [LSB-2]length. jsr PARSE_NAME - - ; update dictionary pointer + inx lda LSB, x - sta .putlen+1 + sta W2 + lda MSB, x + sta W2 + 1 + inx + + ; Abort if empty string. + lda LSB - 2, x + bne + + jmp .on_stack_underflow ; "err" ++ sta .putlen+1 + + ; Move back [W]LATEST. clc adc #3 sta W @@ -160,16 +167,13 @@ HEADER dec LATEST_MSB + lda LATEST_MSB sta W + 1 + + ; Store name length. ldy #0 - ; Store length byte. - lda LSB, x + lda LSB - 2, x sta (W), y - inx - lda LSB, x - sta W2 - lda MSB, x - sta W2 + 1 - ; copy string + + ; Copy name. - lda (W2), y jsr CHAR_TO_LOWERCASE iny @@ -177,14 +181,14 @@ HEADER .putlen cpy #0 bne - - ; store here + + ; Store xt. iny lda HERE_LSB sta (W), y iny lda HERE_MSB sta (W), y - inx rts +BACKLINK "lit", 3 @@ -248,7 +252,7 @@ COMPILE_COMMA +BACKLINK "literal", 7 | F_IMMEDIATE LITERAL dex - lda MSB+1,x + lda MSB + 1,x bne + lda #