diff --git a/apps/zasm/main.asm b/apps/zasm/main.asm index 6ecdfec..7cba9e7 100644 --- a/apps/zasm/main.asm +++ b/apps/zasm/main.asm @@ -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) diff --git a/apps/zasm/tests/test1.asm b/apps/zasm/tests/test1.asm index aff03fb..79fdc2e 100644 --- a/apps/zasm/tests/test1.asm +++ b/apps/zasm/tests/test1.asm @@ -6,8 +6,7 @@ label1: .dw label2 ; comment .db 42 -label2: - .dw 0x42 +label2: .dw 0x42 .dw 3742 .dw 0x3742 ld a, (label1)