1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-23 22:38:06 +11:00

zasm: implement error conditions in .org and .fill

This commit is contained in:
Virgil Dupras 2019-05-27 14:16:40 -04:00
parent 371076190f
commit 31f7c7771d
2 changed files with 24 additions and 2 deletions

View File

@ -142,17 +142,27 @@ handleEQU:
handleORG: handleORG:
call readWord call readWord
jr nz, .badfmt
call parseExpr call parseExpr
ret nz jr nz, .badarg
push ix \ pop hl push ix \ pop hl
call zasmSetOrg call zasmSetOrg
cp a ; ensure Z cp a ; ensure Z
ret ret
.badfmt:
ld a, ERR_BAD_FMT
jr .error
.badarg:
ld a, ERR_BAD_ARG
.error:
call unsetZ
ret
handleFIL: handleFIL:
call readWord call readWord
jr nz, .badfmt
call parseExpr call parseExpr
ret nz jr nz, .badarg
push bc push bc
push ix \ pop bc push ix \ pop bc
xor a xor a
@ -163,6 +173,14 @@ handleFIL:
cp a ; ensure Z cp a ; ensure Z
pop bc pop bc
ret ret
.badfmt:
ld a, ERR_BAD_FMT
jr .error
.badarg:
ld a, ERR_BAD_ARG
.error:
call unsetZ
ret
handleINC: handleINC:
call readWord call readWord

View File

@ -22,11 +22,15 @@ chkerr "ld a, hl" 2
chkerr ".db foo" 2 chkerr ".db foo" 2
chkerr ".dw foo" 2 chkerr ".dw foo" 2
chkerr ".equ foo bar" 2 chkerr ".equ foo bar" 2
chkerr ".org foo" 2
chkerr ".fill foo" 2
chkerr "ld a," 3 chkerr "ld a," 3
chkerr "ld a, 'A" 3 chkerr "ld a, 'A" 3
chkerr ".db 0x42," 3 chkerr ".db 0x42," 3
chkerr ".dw 0x4242," 3 chkerr ".dw 0x4242," 3
chkerr ".equ" 3 chkerr ".equ" 3
chkerr ".equ foo" 3 chkerr ".equ foo" 3
chkerr ".org" 3
chkerr ".fill" 3
chkerr "ld a, 0x100" 4 chkerr "ld a, 0x100" 4
chkerr ".db 0x100" 4 chkerr ".db 0x100" 4