From d76dd54f4bd227933ce76746f4e4d862fe68e05a Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Mon, 27 May 2019 12:12:21 -0400 Subject: [PATCH] zasm: add ERR_OVFL --- apps/zasm/const.asm | 3 +++ apps/zasm/instr.asm | 9 +++++++-- tools/tests/zasm/errtests.sh | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/zasm/const.asm b/apps/zasm/const.asm index 17a6e4d..1781d09 100644 --- a/apps/zasm/const.asm +++ b/apps/zasm/const.asm @@ -8,3 +8,6 @@ ; Code is badly formatted (comma without a following arg, unclosed quote, etc.) .equ ERR_BAD_FMT 0x03 + +; Value specified doesn't fit in its destination byte or word +.equ ERR_OVFL 0x04 diff --git a/apps/zasm/instr.asm b/apps/zasm/instr.asm index 2971c6a..d5075f5 100644 --- a/apps/zasm/instr.asm +++ b/apps/zasm/instr.asm @@ -559,7 +559,9 @@ handleLDrr: ; Compute the upcode for argspec row at (DE) and arguments in curArg{1,2} and ; writes the resulting upcode in instrUpcode. A is the number if bytes written -; to instrUpcode (can be zero if something went wrong). +; to instrUpcode. +; A is zero on error. The only thing that can go wrong in this routine is +; overflow. getUpcode: push ix push de @@ -814,7 +816,7 @@ parseInstruction: ; goal here! call getUpcode or a ; is zero? - jr z, .error + jr z, .overflow ld b, a ; save output byte count ld hl, instrUpcode .loopWrite: @@ -824,6 +826,9 @@ parseInstruction: djnz .loopWrite cp a ; ensure Z jr .end +.overflow: + ld a, ERR_OVFL + jr .error .badfmt: ld a, ERR_BAD_FMT .error: diff --git a/tools/tests/zasm/errtests.sh b/tools/tests/zasm/errtests.sh index c323c4b..028eccd 100755 --- a/tools/tests/zasm/errtests.sh +++ b/tools/tests/zasm/errtests.sh @@ -21,3 +21,4 @@ chkerr "ld a, foo" 2 chkerr "ld a, hl" 2 chkerr "ld a," 3 chkerr "ld a, 'A" 3 +chkerr "ld a, 0x100" 4