From 371076190f033aefc41c4b144bd534ef1192a39a Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Mon, 27 May 2019 14:07:07 -0400 Subject: [PATCH] zasm: implement error conditions in .equ --- apps/zasm/directive.asm | 16 +++++++++++++--- tools/tests/zasm/errtests.sh | 3 +++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/zasm/directive.asm b/apps/zasm/directive.asm index 681366d..ae1800e 100644 --- a/apps/zasm/directive.asm +++ b/apps/zasm/directive.asm @@ -109,6 +109,7 @@ handleEQU: push bc ; Read our constant name call readWord + jr nz, .badfmt ; We can't register our symbol yet: we don't have our value! ; Let's copy it over. ld de, DIREC_SCRATCHPAD @@ -117,14 +118,23 @@ handleEQU: ; Now, read the value associated to it call readWord + jr nz, .badfmt ld hl, scratchpad call parseExpr - jr nz, .end + jr nz, .badarg ld hl, DIREC_SCRATCHPAD push ix \ pop de - call symRegister + call symRegister ; TODO: handle duplicate symbol error, OOM, etc. + cp a ; ensure Z + jr .end +.badfmt: + ld a, ERR_BAD_FMT + jr .error +.badarg: + ld a, ERR_BAD_ARG +.error: + call unsetZ .end: - xor a ; 0 bytes written pop bc pop de pop hl diff --git a/tools/tests/zasm/errtests.sh b/tools/tests/zasm/errtests.sh index 6d178fe..77bb662 100755 --- a/tools/tests/zasm/errtests.sh +++ b/tools/tests/zasm/errtests.sh @@ -21,9 +21,12 @@ chkerr "ld a, foo" 2 chkerr "ld a, hl" 2 chkerr ".db foo" 2 chkerr ".dw foo" 2 +chkerr ".equ foo bar" 2 chkerr "ld a," 3 chkerr "ld a, 'A" 3 chkerr ".db 0x42," 3 chkerr ".dw 0x4242," 3 +chkerr ".equ" 3 +chkerr ".equ foo" 3 chkerr "ld a, 0x100" 4 chkerr ".db 0x100" 4