From 412b3f374a7eea451a1f5636328666bfdf325d18 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Mon, 27 May 2019 11:22:38 -0400 Subject: [PATCH] zasm: add ERR_BAD_ARG --- apps/zasm/const.asm | 8 ++++++++ apps/zasm/glue.asm | 1 + apps/zasm/instr.asm | 8 +++++--- apps/zasm/main.asm | 6 +----- tools/emul/zasm/zasm.bin | Bin 4047 -> 4049 bytes tools/tests/zasm/errtests.sh | 2 +- tools/tests/zasm/test7.asm | 1 + 7 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 apps/zasm/const.asm diff --git a/apps/zasm/const.asm b/apps/zasm/const.asm new file mode 100644 index 0000000..3972478 --- /dev/null +++ b/apps/zasm/const.asm @@ -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 + diff --git a/apps/zasm/glue.asm b/apps/zasm/glue.asm index 47c1492..8d03714 100644 --- a/apps/zasm/glue.asm +++ b/apps/zasm/glue.asm @@ -45,6 +45,7 @@ jp zasmMain +#include "zasm/const.asm" #include "zasm/util.asm" .equ IO_RAMSTART USER_RAMSTART #include "zasm/io.asm" diff --git a/apps/zasm/instr.asm b/apps/zasm/instr.asm index b7a94e2..cefff68 100644 --- a/apps/zasm/instr.asm +++ b/apps/zasm/instr.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 diff --git a/apps/zasm/main.asm b/apps/zasm/main.asm index 8ee4477..23e15fe 100644 --- a/apps/zasm/main.asm +++ b/apps/zasm/main.asm @@ -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: diff --git a/tools/emul/zasm/zasm.bin b/tools/emul/zasm/zasm.bin index 8194765101941049246e233dd9764a23395b4984..dcd66d3f7cf1a57c4defc54e47808e3d470b5402 100644 GIT binary patch delta 835 zcmY*WOK1~O6wRAVX3~5nrXObfv`L!QKDE?3YK0cYE~F;4N$TRw?4;F-6c>sJwjymo zA%d&&7TR^88^ussDu|GjQ0TNgBw#>YpBNCr7#Il^vjPjwTCGbM*PVg1kod!JlR+0z zn{36uJP(Ul z&aFx@l~EB<69|?lgWGXzw+DF5F8#xn%2_Pqe53UN&XW3{1do%%F_t5u@BC{vS zH(0tH5!Z6!q|1An=;R(*A}i!A?e$N!OzWA=LfHfzws9p_s+99xblHE(=Oye_tgvYo z)4?eHpE5|MRqinVk*5a4TydEPMe;$=&IBLlr3qf^#{?AdOXd}8aZ}8 zo~f0zH4wRxFmf}N1;2a1I*hQ3y)%^ktjVTEXDqaH%dohe+lJ-D&6c&Tp?ttGn}3*^ zWgkh_jC4%E3J$P79f$0U0&Lk(+U&L_8$x1l`1Gt delta 847 zcmY*WT}TvR6rFEoXLfb}T&Y2p0kyyR%yxJq+A?&b{ZJIbSaDAwXxp ztk7lDvhuSX`PW;~HH5a-muVjH&lR$!1ncv}Q1V70m)5g>wMaU(m&`-7qD5>2=%cn| ziy*(YZRh3Y%2WA%B%P?4flJrCW%jk4{5Pyp&Gv$1?J6b&_KU6Dbc@M{5#)COACE zV99PN{+)B+C6BG5095=xl~?5pRhfzb(P<+1XweA<NdMhF$6wR+j=Y2i}4vCAxq?JnY1#dCS<<+|*# zs1@e>Vm_Xd4igeAq(_3seIPUy4-S#m(V*Kx`hCCva?*F}3b(pIMq^^V%)#3>{74Br zxi|h=^jr?H>+kGStn)NZ;5odCpWruIuY0;_R!ME<3OeYJjj@bTEM&vlQ}-!X9VRa# zxlKKv^o6v~?isYFUG#{qHAR$)dD0w-lRoXXXP~)9*=bU;2iPbU^ChD@oa}B(l4wM1 zAbZ-DXXwa2mXXw%B>ifJoE=G3O3m*LT_003^QH;EzE4`zAWPn=LMg42>Ct%;?aZhq zy>mk~8L`ncw`G*|QVZGn_yYNa(|V|F5>`Yn=~2Xhm6w-1R)wQhTaj@>dTOaaX0=D& ZfY7Aq=Zke-rP diff --git a/tools/tests/zasm/errtests.sh b/tools/tests/zasm/errtests.sh index a9e9de9..7bf15b2 100755 --- a/tools/tests/zasm/errtests.sh +++ b/tools/tests/zasm/errtests.sh @@ -17,4 +17,4 @@ chkerr() { } chkerr "foo" 1 - +chkerr "ld a, foo" 2 diff --git a/tools/tests/zasm/test7.asm b/tools/tests/zasm/test7.asm index 3894ff3..041f81b 100644 --- a/tools/tests/zasm/test7.asm +++ b/tools/tests/zasm/test7.asm @@ -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"