zasm: add ERR_BAD_ARG
This commit is contained in:
parent
af2c561c6b
commit
412b3f374a
8
apps/zasm/const.asm
Normal file
8
apps/zasm/const.asm
Normal file
@ -0,0 +1,8 @@
|
||||
; *** Errors ***
|
||||
; Unknown instruction or directive
|
||||
.equ ERR_UNKNOWN 0x01
|
||||
|
||||
; Bad argument: Doesn't match any constant argspec or, if an expression,
|
||||
; contains references to undefined symbols.
|
||||
.equ ERR_BAD_ARG 0x02
|
||||
|
@ -45,6 +45,7 @@
|
||||
|
||||
jp zasmMain
|
||||
|
||||
#include "zasm/const.asm"
|
||||
#include "zasm/util.asm"
|
||||
.equ IO_RAMSTART USER_RAMSTART
|
||||
#include "zasm/io.asm"
|
||||
|
@ -766,12 +766,13 @@ processArg:
|
||||
cp a ; ensure Z is set
|
||||
ret
|
||||
.error:
|
||||
ld a, ERR_BAD_ARG
|
||||
call unsetZ
|
||||
ret
|
||||
|
||||
; Parse instruction specified in A (I_* const) with args in I/O and write
|
||||
; resulting opcode(s) in I/O.
|
||||
; Sets Z on success.
|
||||
; Sets Z on success. On error, A contains an error code (ERR_*)
|
||||
parseInstruction:
|
||||
push bc
|
||||
push hl
|
||||
@ -786,14 +787,14 @@ parseInstruction:
|
||||
jr nz, .nomorearg
|
||||
ld de, curArg1
|
||||
call processArg
|
||||
jr nz, .error
|
||||
jr nz, .error ; A is set to error
|
||||
call readComma
|
||||
jr nz, .nomorearg
|
||||
call readWord
|
||||
jr nz, .error
|
||||
ld de, curArg2
|
||||
call processArg
|
||||
jr nz, .error
|
||||
jr nz, .error ; A is set to error
|
||||
.nomorearg:
|
||||
; Parsing done, no error, let's move forward to instr row matching!
|
||||
ld de, instrTBl
|
||||
@ -824,6 +825,7 @@ parseInstruction:
|
||||
cp a ; ensure Z
|
||||
jr .end
|
||||
.error:
|
||||
; A is set to error already
|
||||
call unsetZ
|
||||
.end:
|
||||
pop de
|
||||
|
@ -15,10 +15,6 @@
|
||||
.equ ZASM_ORG ZASM_CTX_PC+2
|
||||
.equ ZASM_RAMEND ZASM_ORG+2
|
||||
|
||||
; *** Errors ***
|
||||
; Unknown instruction or directive
|
||||
.equ ERR_UNKWN 0x01
|
||||
|
||||
; Read file through blockdev ID in H and outputs its upcodes through blockdev
|
||||
; ID in L.
|
||||
zasmMain:
|
||||
@ -115,7 +111,7 @@ parseLine:
|
||||
cp TOK_EOF
|
||||
ret z ; We're finished, no error.
|
||||
; Bad token
|
||||
ld a, ERR_UNKWN
|
||||
ld a, ERR_UNKNOWN
|
||||
jp unsetZ ; return with Z unset
|
||||
|
||||
_parseInstr:
|
||||
|
Binary file not shown.
@ -17,4 +17,4 @@ chkerr() {
|
||||
}
|
||||
|
||||
chkerr "foo" 1
|
||||
|
||||
chkerr "ld a, foo" 2
|
||||
|
@ -21,6 +21,7 @@
|
||||
.equ fsSeek 0x30
|
||||
.equ fsTell 0x33
|
||||
|
||||
#include "zasm/const.asm"
|
||||
#include "zasm/util.asm"
|
||||
.equ IO_RAMSTART USER_RAMSTART
|
||||
#include "zasm/io.asm"
|
||||
|
Loading…
Reference in New Issue
Block a user