1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-24 02:58:06 +11:00

zasm: allow single quote to contain whitespace

This commit is contained in:
Virgil Dupras 2019-05-17 17:22:16 -04:00
parent 40d5530666
commit 21c49d80cf
2 changed files with 20 additions and 2 deletions

View File

@ -92,10 +92,12 @@ readWord:
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
; Let's first check if we open with a quote. If we do, let's have the ; Are we opening a double quote?
; special quote treatment.
cp '"' cp '"'
jr z, .insideQuote jr z, .insideQuote
; Are we opening a single quote?
cp 0x27 ; '
jr z, .singleQuote
.loop2: .loop2:
ld (hl), a ld (hl), a
inc hl inc hl
@ -134,6 +136,21 @@ readWord:
djnz .insideQuote djnz .insideQuote
; out of space. error. ; out of space. error.
jr .error jr .error
.singleQuote:
; single quote is more straightforward: we have 3 chars and we put them
; right in scratchpad
ld (hl), a
call ioGetC
or a
jr z, .error
inc hl
ld (hl), a
call ioGetC
cp 0x27 ; '
jr nz, .error
inc hl
ld (hl), a
jr .loop2
; 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.

View File

@ -5,5 +5,6 @@ ld a, 0x42
ld hl, 0x4234 ld hl, 0x4234
ld hl, (0x4234) ld hl, (0x4234)
ld a, 'X' ld a, 'X'
ld a, ' '
ld a, 'a' ; don't upcase! ld a, 'a' ; don't upcase!
.db "bonjour allo", 0 .db "bonjour allo", 0