From b298e607bd43e11cae5d4bb2da3aacb3d20ca9b3 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Mon, 27 May 2019 14:21:46 -0400 Subject: [PATCH] zasm: implement error conditions for #inc --- apps/zasm/const.asm | 2 ++ apps/zasm/directive.asm | 16 ++++++++++++---- tools/tests/zasm/errtests.sh | 3 +++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/apps/zasm/const.asm b/apps/zasm/const.asm index 1781d09..2f9db4e 100644 --- a/apps/zasm/const.asm +++ b/apps/zasm/const.asm @@ -11,3 +11,5 @@ ; Value specified doesn't fit in its destination byte or word .equ ERR_OVFL 0x04 + +.equ ERR_FILENOTFOUND 0x05 diff --git a/apps/zasm/directive.asm b/apps/zasm/directive.asm index 74fd4bd..99d7b88 100644 --- a/apps/zasm/directive.asm +++ b/apps/zasm/directive.asm @@ -184,13 +184,21 @@ handleFIL: handleINC: call readWord - jr nz, .end + jr nz, .badfmt ; HL points to scratchpad call enterDoubleQuotes - jr nz, .end + jr nz, .badfmt call ioOpenInclude -.end: - xor a ; zero bytes written + jr nz, .badfn + cp a ; ensure Z + ret +.badfmt: + ld a, ERR_BAD_FMT + jr .error +.badfn: + ld a, ERR_FILENOTFOUND +.error: + call unsetZ ret ; Reads string in (HL) and returns the corresponding ID (D_*) in A. Sets Z if diff --git a/tools/tests/zasm/errtests.sh b/tools/tests/zasm/errtests.sh index 596f4c8..b48d8cf 100755 --- a/tools/tests/zasm/errtests.sh +++ b/tools/tests/zasm/errtests.sh @@ -32,5 +32,8 @@ chkerr ".equ" 3 chkerr ".equ foo" 3 chkerr ".org" 3 chkerr ".fill" 3 +chkerr "#inc" 3 +chkerr "#inc foo" 3 chkerr "ld a, 0x100" 4 chkerr ".db 0x100" 4 +chkerr "#inc \"doesnotexist\"" 5