zasm: improve comma processing
We don't treat "," exactly as a whitespace anymore. We have specific processing for it.
This commit is contained in:
parent
4c37d869f4
commit
6547e83f20
@ -710,15 +710,9 @@ getUpcode:
|
|||||||
pop ix
|
pop ix
|
||||||
ret
|
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.
|
; Sets Z on success, reset on error.
|
||||||
processArg:
|
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
|
call parseArg
|
||||||
cp 0xff
|
cp 0xff
|
||||||
jr z, .error
|
jr z, .error
|
||||||
@ -737,10 +731,6 @@ processArg:
|
|||||||
.error:
|
.error:
|
||||||
call unsetZ
|
call unsetZ
|
||||||
ret
|
ret
|
||||||
.noarg:
|
|
||||||
xor a
|
|
||||||
ld (de), a
|
|
||||||
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 (instrUpcode). Returns the number of bytes written in
|
; 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.
|
; A is reused in matchPrimaryRow but that register is way too changing.
|
||||||
; Let's keep a copy in a more cosy register.
|
; Let's keep a copy in a more cosy register.
|
||||||
ld c, a
|
ld c, a
|
||||||
|
xor a
|
||||||
|
ld (curArg1), a
|
||||||
|
ld (curArg2), a
|
||||||
|
call readWord
|
||||||
|
jr nz, .nomorearg
|
||||||
ld de, curArg1
|
ld de, curArg1
|
||||||
call processArg
|
call processArg
|
||||||
jr nz, .error
|
jr nz, .error
|
||||||
|
call readComma
|
||||||
|
jr nz, .nomorearg
|
||||||
|
call readWord
|
||||||
|
jr nz, .error
|
||||||
ld de, curArg2
|
ld de, curArg2
|
||||||
call processArg
|
call processArg
|
||||||
jr nz, .error
|
jr nz, .error
|
||||||
|
.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
|
||||||
ld b, INSTR_TBL_CNT
|
ld b, INSTR_TBL_CNT
|
||||||
|
@ -34,8 +34,6 @@ isSep:
|
|||||||
cp ' '
|
cp ' '
|
||||||
ret z
|
ret z
|
||||||
cp 0x09
|
cp 0x09
|
||||||
ret z
|
|
||||||
cp ','
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Sets Z is A is ' ', ',', ';', CR, LF, or null.
|
; Sets Z is A is ' ', ',', ';', CR, LF, or null.
|
||||||
@ -100,6 +98,8 @@ readWord:
|
|||||||
call ioGetC
|
call ioGetC
|
||||||
call isSepOrLineEnd
|
call isSepOrLineEnd
|
||||||
jr z, .success
|
jr z, .success
|
||||||
|
cp ','
|
||||||
|
jr z, .success
|
||||||
djnz .loop2
|
djnz .loop2
|
||||||
; out of space. error.
|
; out of space. error.
|
||||||
.error:
|
.error:
|
||||||
@ -118,6 +118,16 @@ readWord:
|
|||||||
pop bc
|
pop bc
|
||||||
ret
|
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
|
; 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
|
; necessary. This skips all whitespace, \n, \r, comments until we reach the
|
||||||
; first non-comment character. Then, we put it back (ioPutBack) and return.
|
; first non-comment character. Then, we put it back (ioPutBack) and return.
|
||||||
|
Loading…
Reference in New Issue
Block a user