mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-27 14:18:06 +11:00
zasm: accept whitespaces before separating comma
This commit is contained in:
parent
3b1ef2b9af
commit
ea8477bb91
@ -71,6 +71,14 @@ isLabel:
|
|||||||
pop hl
|
pop hl
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; Read I/O as long as it's whitespace. When it's not, stop and return the last
|
||||||
|
; read char in A
|
||||||
|
_eatWhitespace:
|
||||||
|
call ioGetC
|
||||||
|
call isSep
|
||||||
|
ret nz
|
||||||
|
jr _eatWhitespace
|
||||||
|
|
||||||
; Read ioGetC until a word starts, then read ioGetC as long as there is no
|
; Read ioGetC until a word starts, then read ioGetC as long as there is no
|
||||||
; separator and put that contents in (scratchpad), null terminated, for a
|
; separator and put that contents in (scratchpad), null terminated, for a
|
||||||
; maximum of SCRATCHPAD_SIZE-1 characters.
|
; maximum of SCRATCHPAD_SIZE-1 characters.
|
||||||
@ -81,14 +89,9 @@ isLabel:
|
|||||||
readWord:
|
readWord:
|
||||||
push bc
|
push bc
|
||||||
; Get to word
|
; Get to word
|
||||||
.loop1:
|
call _eatWhitespace
|
||||||
call ioGetC
|
|
||||||
call isLineEndOrComment
|
call isLineEndOrComment
|
||||||
jr z, .error
|
jr z, .error
|
||||||
call isSep
|
|
||||||
jr nz, .read
|
|
||||||
jr .loop1
|
|
||||||
.read:
|
|
||||||
ld hl, scratchpad
|
ld hl, scratchpad
|
||||||
ld b, SCRATCHPAD_SIZE-1
|
ld b, SCRATCHPAD_SIZE-1
|
||||||
; A contains the first letter to read
|
; A contains the first letter to read
|
||||||
@ -98,7 +101,7 @@ readWord:
|
|||||||
; Are we opening a single quote?
|
; Are we opening a single quote?
|
||||||
cp 0x27 ; '
|
cp 0x27 ; '
|
||||||
jr z, .singleQuote
|
jr z, .singleQuote
|
||||||
.loop2:
|
.loop:
|
||||||
ld (hl), a
|
ld (hl), a
|
||||||
inc hl
|
inc hl
|
||||||
call ioGetC
|
call ioGetC
|
||||||
@ -106,7 +109,7 @@ readWord:
|
|||||||
jr z, .success
|
jr z, .success
|
||||||
cp ','
|
cp ','
|
||||||
jr z, .success
|
jr z, .success
|
||||||
djnz .loop2
|
djnz .loop
|
||||||
; out of space. error.
|
; out of space. error.
|
||||||
.error:
|
.error:
|
||||||
; We need to put the last char we've read back so that gotoNextLine
|
; We need to put the last char we've read back so that gotoNextLine
|
||||||
@ -129,7 +132,7 @@ readWord:
|
|||||||
inc hl
|
inc hl
|
||||||
call ioGetC
|
call ioGetC
|
||||||
cp '"'
|
cp '"'
|
||||||
jr z, .loop2 ; ending the quote ends the word
|
jr z, .loop ; ending the quote ends the word
|
||||||
call isLineEnd
|
call isLineEnd
|
||||||
jr z, .error ; ending the line without closing the quote,
|
jr z, .error ; ending the line without closing the quote,
|
||||||
; nope.
|
; nope.
|
||||||
@ -150,12 +153,12 @@ readWord:
|
|||||||
jr nz, .error
|
jr nz, .error
|
||||||
inc hl
|
inc hl
|
||||||
ld (hl), a
|
ld (hl), a
|
||||||
jr .loop2
|
jr .loop
|
||||||
|
|
||||||
; Reads the next char in I/O. If it's a comma, Set Z and return. If it's not,
|
; 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.
|
; Put the read char back in I/O and unset Z.
|
||||||
readComma:
|
readComma:
|
||||||
call ioGetC
|
call _eatWhitespace
|
||||||
cp ','
|
cp ','
|
||||||
ret z
|
ret z
|
||||||
call ioPutBack
|
call ioPutBack
|
||||||
|
@ -20,7 +20,8 @@ label2: .dw 0x42
|
|||||||
ld l, (ix+1)
|
ld l, (ix+1)
|
||||||
ld hl, 0x100
|
ld hl, 0x100
|
||||||
.equ baz 0x20
|
.equ baz 0x20
|
||||||
ld b, baz-3
|
; accept space before comma
|
||||||
|
ld b , baz-3
|
||||||
rl d
|
rl d
|
||||||
rr e
|
rr e
|
||||||
rlc c
|
rlc c
|
||||||
|
Loading…
Reference in New Issue
Block a user