1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-23 19:48:06 +11:00

zasm: allow for whitespace inside string literals

Also, increase scratchpad size. It wasn't big enough for some
expressions in shell unit.
This commit is contained in:
Virgil Dupras 2019-05-17 16:44:08 -04:00
parent f9dac15449
commit 556be3f0ce
2 changed files with 19 additions and 2 deletions

View File

@ -5,7 +5,7 @@ TOK_LABEL .equ 0x03
TOK_EOF .equ 0xfe ; end of file
TOK_BAD .equ 0xff
.equ SCRATCHPAD_SIZE 0x20
.equ SCRATCHPAD_SIZE 0x40
; *** Variables ***
scratchpad:
.fill SCRATCHPAD_SIZE
@ -92,6 +92,10 @@ readWord:
ld hl, scratchpad
ld b, SCRATCHPAD_SIZE-1
; A contains the first letter to read
; Let's first check if we open with a quote. If we do, let's have the
; special quote treatment.
cp '"'
jr z, .insideQuote
.loop2:
ld (hl), a
inc hl
@ -117,6 +121,19 @@ readWord:
.end:
pop bc
ret
.insideQuote:
; inside quotes, we accept literal whitespaces, but not line ends.
ld (hl), a
inc hl
call ioGetC
cp '"'
jr z, .loop2 ; ending the quote ends the word
call isLineEnd
jr z, .error ; ending the line without closing the quote,
; nope.
djnz .insideQuote
; out of space. error.
jr .error
; 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.

View File

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