Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

abort with error on empty HEADER name #564

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 23 additions & 19 deletions asm/compiler.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -160,31 +167,28 @@ 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
sta (W), y
.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
Expand Down Expand Up @@ -248,7 +252,7 @@ COMPILE_COMMA
+BACKLINK "literal", 7 | F_IMMEDIATE
LITERAL
dex
lda MSB+1,x
lda MSB + 1,x
bne +
lda #<LITC
sta LSB,x
Expand Down