1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-23 16:18:05 +11:00

zasm: add ERR_BAD_ARG

This commit is contained in:
Virgil Dupras 2019-05-27 11:22:38 -04:00
parent af2c561c6b
commit 412b3f374a
7 changed files with 17 additions and 9 deletions

8
apps/zasm/const.asm Normal file
View 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

View File

@ -45,6 +45,7 @@
jp zasmMain
#include "zasm/const.asm"
#include "zasm/util.asm"
.equ IO_RAMSTART USER_RAMSTART
#include "zasm/io.asm"

View File

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

View File

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

View File

@ -17,4 +17,4 @@ chkerr() {
}
chkerr "foo" 1
chkerr "ld a, foo" 2

View File

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