瀏覽代碼

zasm: allow for whitespace inside string literals

Also, increase scratchpad size. It wasn't big enough for some
expressions in shell unit.
pull/10/head
Virgil Dupras 5 年之前
父節點
當前提交
556be3f0ce
共有 2 個檔案被更改,包括 19 行新增2 行删除
  1. +18
    -1
      apps/zasm/tok.asm
  2. +1
    -1
      tools/tests/zasm/test4.asm

+ 18
- 1
apps/zasm/tok.asm 查看文件

@@ -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.


+ 1
- 1
tools/tests/zasm/test4.asm 查看文件

@@ -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

Loading…
取消
儲存