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