Browse Source

zasm: add ERR_BAD_ARG

pull/10/head
Virgil Dupras 5 years ago
parent
commit
412b3f374a
7 changed files with 17 additions and 9 deletions
  1. +8
    -0
      apps/zasm/const.asm
  2. +1
    -0
      apps/zasm/glue.asm
  3. +5
    -3
      apps/zasm/instr.asm
  4. +1
    -5
      apps/zasm/main.asm
  5. BIN
      tools/emul/zasm/zasm.bin
  6. +1
    -1
      tools/tests/zasm/errtests.sh
  7. +1
    -0
      tools/tests/zasm/test7.asm

+ 8
- 0
apps/zasm/const.asm 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


+ 1
- 0
apps/zasm/glue.asm 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"


+ 5
- 3
apps/zasm/instr.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


+ 1
- 5
apps/zasm/main.asm 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:


BIN
tools/emul/zasm/zasm.bin View File


+ 1
- 1
tools/tests/zasm/errtests.sh View File

@@ -17,4 +17,4 @@ chkerr() {
}

chkerr "foo" 1
chkerr "ld a, foo" 2

+ 1
- 0
tools/tests/zasm/test7.asm 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"


Loading…
Cancel
Save