1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-12-25 04:38:05 +11:00

zasm: support inline labels

That is, labels with code following right afterwards.
This commit is contained in:
Virgil Dupras 2019-05-14 14:10:20 -04:00
parent a486a2a81e
commit 2c0166814f
2 changed files with 13 additions and 6 deletions

View File

@ -108,9 +108,8 @@ zasmParseFile:
ret nz ; error
jr .loop
; Parse line in (HL), write the resulting opcode(s) in (DE) and increases
; (curOutputOffset) by the number of bytes written. Advances HL where
; tokenization stopped and DE to where we should write the next upcode.
; Parse line in (HL), write the resulting opcode(s) through ioPutC and increases
; (curOutputOffset) by the number of bytes written.
; Sets Z if parse was successful, unset if there was an error or EOF.
parseLine:
push bc
@ -160,6 +159,8 @@ parseLine:
jr .success
.label:
; The string in (scratchpad) is a label with its trailing ':' removed.
ex hl, de ; save current HL (end of label) in DE,
; we will need it later
ld hl, scratchpad
call zasmIsFirstPass
jr z, .registerLabel ; When we encounter a label in the first
@ -170,8 +171,15 @@ parseLine:
call symIsLabelLocal
jr z, .success ; local? nothing to do.
call symSetContext
jr nz, .error ; NZ? this means that (HL) couldn't be
; found in symbol list. Weird
; We're finished here. However, because it's a label, it's possible that
; another logical line follows directly after the label. Let's parse
; this and propagate error.
ex hl, de ; recall end of label position from DE
; into HL
call parseLine
jr z, .success
; NZ? this means that (HL) couldn't be found in symbol list. Weird
jr .error
.registerLabel:
ld de, (curOutputOffset)

View File

@ -6,8 +6,7 @@ label1:
.dw label2
; comment
.db 42
label2:
.dw 0x42
label2: .dw 0x42
.dw 3742
.dw 0x3742
ld a, (label1)