From 99a7c94c9f7cdfaeeade1c552ed9928d2e339635 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Tue, 14 May 2019 14:35:34 -0400 Subject: [PATCH] zasm: make "double parsing" a bit more solid It was previously skipped on a local label. --- apps/zasm/main.asm | 19 +++++++++---------- apps/zasm/tests/test3.asm | 3 +-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/apps/zasm/main.asm b/apps/zasm/main.asm index f8bd606..4b9ea69 100644 --- a/apps/zasm/main.asm +++ b/apps/zasm/main.asm @@ -133,7 +133,14 @@ parseLine: call _parseDirec jr .end ; Z is correct .label: + push hl call _parseLabel + pop hl + jr nz, .end ; error out + ; 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. + call parseLine ; Continue to .end, Z has proper value .end: pop bc @@ -194,18 +201,10 @@ _parseLabel: ; When we're not in the first pass, we set the context (if label is not ; local) to that label. call symIsLabelLocal - jr z, .noContext ; local? don't set context + jr z, .success ; local? don't set context call symSetContext - jr nz, .error ; NZ? this means that (HL) couldn't be - ; found in symbol list. Weird -.noContext: - ; 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/test3.asm b/apps/zasm/tests/test3.asm index 141b16f..f985512 100644 --- a/apps/zasm/tests/test3.asm +++ b/apps/zasm/tests/test3.asm @@ -4,8 +4,7 @@ addDE: add a, e jr nc, .end ; no carry? skip inc inc d -.end: - ld e, a +.end: ld e, a pop af ret