소스 검색

zasm: implement error conditions in .equ

pull/10/head
Virgil Dupras 5 년 전
부모
커밋
371076190f
2개의 변경된 파일16개의 추가작업 그리고 3개의 파일을 삭제
  1. +13
    -3
      apps/zasm/directive.asm
  2. +3
    -0
      tools/tests/zasm/errtests.sh

+ 13
- 3
apps/zasm/directive.asm 파일 보기

@@ -109,6 +109,7 @@ handleEQU:
push bc
; Read our constant name
call readWord
jr nz, .badfmt
; We can't register our symbol yet: we don't have our value!
; Let's copy it over.
ld de, DIREC_SCRATCHPAD
@@ -117,14 +118,23 @@ handleEQU:

; Now, read the value associated to it
call readWord
jr nz, .badfmt
ld hl, scratchpad
call parseExpr
jr nz, .end
jr nz, .badarg
ld hl, DIREC_SCRATCHPAD
push ix \ pop de
call symRegister
call symRegister ; TODO: handle duplicate symbol error, OOM, etc.
cp a ; ensure Z
jr .end
.badfmt:
ld a, ERR_BAD_FMT
jr .error
.badarg:
ld a, ERR_BAD_ARG
.error:
call unsetZ
.end:
xor a ; 0 bytes written
pop bc
pop de
pop hl


+ 3
- 0
tools/tests/zasm/errtests.sh 파일 보기

@@ -21,9 +21,12 @@ chkerr "ld a, foo" 2
chkerr "ld a, hl" 2
chkerr ".db foo" 2
chkerr ".dw foo" 2
chkerr ".equ foo bar" 2
chkerr "ld a," 3
chkerr "ld a, 'A" 3
chkerr ".db 0x42," 3
chkerr ".dw 0x4242," 3
chkerr ".equ" 3
chkerr ".equ foo" 3
chkerr "ld a, 0x100" 4
chkerr ".db 0x100" 4

불러오는 중...
취소
저장