Selaa lähdekoodia

zasm: implement error conditions in .db

pull/10/head
Virgil Dupras 5 vuotta sitten
vanhempi
commit
f5d4321ece
3 muutettua tiedostoa jossa 29 lisäystä ja 2 poistoa
  1. +26
    -1
      apps/zasm/directive.asm
  2. +0
    -1
      apps/zasm/main.asm
  3. +3
    -0
      tools/tests/zasm/errtests.sh

+ 26
- 1
apps/zasm/directive.asm Näytä tiedosto

@@ -35,18 +35,37 @@ handleDB:
push hl
.loop:
call readWord
jr nz, .badfmt
ld hl, scratchpad
call enterDoubleQuotes
jr z, .stringLiteral
call parseExpr
jr nz, .badarg
push ix \ pop hl
ld a, h
or a ; cp 0
jr nz, .overflow ; not zero? overflow
ld a, l
call ioPutC
.stopStrLit:
call readComma
jr z, .loop
cp a ; ensure Z
pop hl
ret
.badfmt:
ld a, ERR_BAD_FMT
jr .error
.badarg:
ld a, ERR_BAD_ARG
jr .error
.overflow:
ld a, ERR_OVFL
.error:
call unsetZ
pop hl
ret

.stringLiteral:
ld a, (hl)
inc hl
@@ -69,6 +88,7 @@ handleDW:
call ioPutC
call readComma
jr z, .loop
cp a ; ensure Z
pop hl
ret

@@ -104,7 +124,9 @@ handleORG:
call parseExpr
ret nz
push ix \ pop hl
jp zasmSetOrg
call zasmSetOrg
cp a ; ensure Z
ret

handleFIL:
call readWord
@@ -117,6 +139,7 @@ handleFIL:
.loop:
call ioPutC
djnz .loop
cp a ; ensure Z
pop bc
ret

@@ -147,6 +170,8 @@ getDirectiveID:
; Parse directive specified in A (D_* const) with args in I/O and act in
; an appropriate manner. If the directive results in writing data at its
; current location, that data is directly written through ioPutC.
; Each directive has the same return value pattern: Z on success, not-Z on
; error, A contains the error number (ERR_*).
parseDirective:
push de
; double A to have a proper offset in directiveHandlers


+ 0
- 1
apps/zasm/main.asm Näytä tiedosto

@@ -121,7 +121,6 @@ _parseInstr:
_parseDirec:
ld a, c ; D_*
call parseDirective
cp a ; ensure Z
ret

_parseLabel:


+ 3
- 0
tools/tests/zasm/errtests.sh Näytä tiedosto

@@ -19,6 +19,9 @@ chkerr() {
chkerr "foo" 1
chkerr "ld a, foo" 2
chkerr "ld a, hl" 2
chkerr ".db foo" 2
chkerr "ld a," 3
chkerr "ld a, 'A" 3
chkerr ".db 0x42," 3
chkerr "ld a, 0x100" 4
chkerr ".db 0x100" 4

Loading…
Peruuta
Tallenna