Browse Source

zasm: add ERR_OVFL

pull/10/head
Virgil Dupras 5 years ago
parent
commit
d76dd54f4b
3 changed files with 11 additions and 2 deletions
  1. +3
    -0
      apps/zasm/const.asm
  2. +7
    -2
      apps/zasm/instr.asm
  3. +1
    -0
      tools/tests/zasm/errtests.sh

+ 3
- 0
apps/zasm/const.asm View File

@@ -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

+ 7
- 2
apps/zasm/instr.asm View File

@@ -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:


+ 1
- 0
tools/tests/zasm/errtests.sh View File

@@ -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

Loading…
Cancel
Save