diff --git a/apps/zasm/instr.asm b/apps/zasm/instr.asm index 7f82b82..7b6fb95 100644 --- a/apps/zasm/instr.asm +++ b/apps/zasm/instr.asm @@ -710,15 +710,9 @@ getUpcode: pop ix ret -; Parse next argument in I/O and place it in (DE) +; Parse argument in (HL) and place it in (DE) ; Sets Z on success, reset on error. processArg: - call readWord - jr nz, .noarg - ; Read word is in (HL). Now, let's push - ; that HL value and replace it with (scratchpad) so that we can parse - ; that arg. - call parseArg cp 0xff jr z, .error @@ -737,10 +731,6 @@ processArg: .error: call unsetZ ret -.noarg: - xor a - ld (de), a - ret ; Parse instruction specified in A (I_* const) with args in I/O and write ; resulting opcode(s) in (instrUpcode). Returns the number of bytes written in @@ -752,12 +742,22 @@ parseInstruction: ; A is reused in matchPrimaryRow but that register is way too changing. ; Let's keep a copy in a more cosy register. ld c, a + xor a + ld (curArg1), a + ld (curArg2), a + call readWord + jr nz, .nomorearg ld de, curArg1 call processArg jr nz, .error + call readComma + jr nz, .nomorearg + call readWord + jr nz, .error ld de, curArg2 call processArg jr nz, .error +.nomorearg: ; Parsing done, no error, let's move forward to instr row matching! ld de, instrTBl ld b, INSTR_TBL_CNT diff --git a/apps/zasm/tok.asm b/apps/zasm/tok.asm index 3049def..5f0fce7 100644 --- a/apps/zasm/tok.asm +++ b/apps/zasm/tok.asm @@ -34,8 +34,6 @@ isSep: cp ' ' ret z cp 0x09 - ret z - cp ',' ret ; Sets Z is A is ' ', ',', ';', CR, LF, or null. @@ -100,6 +98,8 @@ readWord: call ioGetC call isSepOrLineEnd jr z, .success + cp ',' + jr z, .success djnz .loop2 ; out of space. error. .error: @@ -118,6 +118,16 @@ readWord: pop bc ret +; Reads the next char in I/O. If it's a comma, Set Z and return. If it's not, +; Put the read char back in I/O and unset Z. +readComma: + call ioGetC + cp ',' + ret z + call ioPutBack + call unsetZ + ret + ; Read ioGetC until we reach the beginning of next line, skipping comments if ; necessary. This skips all whitespace, \n, \r, comments until we reach the ; first non-comment character. Then, we put it back (ioPutBack) and return.