mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-24 01:08:06 +11:00
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
|
jp zasmMain
|
||||||
|
|
||||||
|
#include "zasm/const.asm"
|
||||||
#include "zasm/util.asm"
|
#include "zasm/util.asm"
|
||||||
.equ IO_RAMSTART USER_RAMSTART
|
.equ IO_RAMSTART USER_RAMSTART
|
||||||
#include "zasm/io.asm"
|
#include "zasm/io.asm"
|
||||||
|
@ -766,12 +766,13 @@ processArg:
|
|||||||
cp a ; ensure Z is set
|
cp a ; ensure Z is set
|
||||||
ret
|
ret
|
||||||
.error:
|
.error:
|
||||||
|
ld a, ERR_BAD_ARG
|
||||||
call unsetZ
|
call unsetZ
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Parse instruction specified in A (I_* const) with args in I/O and write
|
; Parse instruction specified in A (I_* const) with args in I/O and write
|
||||||
; resulting opcode(s) in I/O.
|
; resulting opcode(s) in I/O.
|
||||||
; Sets Z on success.
|
; Sets Z on success. On error, A contains an error code (ERR_*)
|
||||||
parseInstruction:
|
parseInstruction:
|
||||||
push bc
|
push bc
|
||||||
push hl
|
push hl
|
||||||
@ -786,14 +787,14 @@ parseInstruction:
|
|||||||
jr nz, .nomorearg
|
jr nz, .nomorearg
|
||||||
ld de, curArg1
|
ld de, curArg1
|
||||||
call processArg
|
call processArg
|
||||||
jr nz, .error
|
jr nz, .error ; A is set to error
|
||||||
call readComma
|
call readComma
|
||||||
jr nz, .nomorearg
|
jr nz, .nomorearg
|
||||||
call readWord
|
call readWord
|
||||||
jr nz, .error
|
jr nz, .error
|
||||||
ld de, curArg2
|
ld de, curArg2
|
||||||
call processArg
|
call processArg
|
||||||
jr nz, .error
|
jr nz, .error ; A is set to error
|
||||||
.nomorearg:
|
.nomorearg:
|
||||||
; Parsing done, no error, let's move forward to instr row matching!
|
; Parsing done, no error, let's move forward to instr row matching!
|
||||||
ld de, instrTBl
|
ld de, instrTBl
|
||||||
@ -824,6 +825,7 @@ parseInstruction:
|
|||||||
cp a ; ensure Z
|
cp a ; ensure Z
|
||||||
jr .end
|
jr .end
|
||||||
.error:
|
.error:
|
||||||
|
; A is set to error already
|
||||||
call unsetZ
|
call unsetZ
|
||||||
.end:
|
.end:
|
||||||
pop de
|
pop de
|
||||||
|
@ -15,10 +15,6 @@
|
|||||||
.equ ZASM_ORG ZASM_CTX_PC+2
|
.equ ZASM_ORG ZASM_CTX_PC+2
|
||||||
.equ ZASM_RAMEND ZASM_ORG+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
|
; Read file through blockdev ID in H and outputs its upcodes through blockdev
|
||||||
; ID in L.
|
; ID in L.
|
||||||
zasmMain:
|
zasmMain:
|
||||||
@ -115,7 +111,7 @@ parseLine:
|
|||||||
cp TOK_EOF
|
cp TOK_EOF
|
||||||
ret z ; We're finished, no error.
|
ret z ; We're finished, no error.
|
||||||
; Bad token
|
; Bad token
|
||||||
ld a, ERR_UNKWN
|
ld a, ERR_UNKNOWN
|
||||||
jp unsetZ ; return with Z unset
|
jp unsetZ ; return with Z unset
|
||||||
|
|
||||||
_parseInstr:
|
_parseInstr:
|
||||||
|
Binary file not shown.
@ -17,4 +17,4 @@ chkerr() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
chkerr "foo" 1
|
chkerr "foo" 1
|
||||||
|
chkerr "ld a, foo" 2
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
.equ fsSeek 0x30
|
.equ fsSeek 0x30
|
||||||
.equ fsTell 0x33
|
.equ fsTell 0x33
|
||||||
|
|
||||||
|
#include "zasm/const.asm"
|
||||||
#include "zasm/util.asm"
|
#include "zasm/util.asm"
|
||||||
.equ IO_RAMSTART USER_RAMSTART
|
.equ IO_RAMSTART USER_RAMSTART
|
||||||
#include "zasm/io.asm"
|
#include "zasm/io.asm"
|
||||||
|
Loading…
Reference in New Issue
Block a user