From 556be3f0cea79bb8976d502f12ce2da8b2b51605 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Fri, 17 May 2019 16:44:08 -0400 Subject: [PATCH] zasm: allow for whitespace inside string literals Also, increase scratchpad size. It wasn't big enough for some expressions in shell unit. --- apps/zasm/tok.asm | 19 ++++++++++++++++++- tools/tests/zasm/test4.asm | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/zasm/tok.asm b/apps/zasm/tok.asm index 5f0fce7..82f5493 100644 --- a/apps/zasm/tok.asm +++ b/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. diff --git a/tools/tests/zasm/test4.asm b/tools/tests/zasm/test4.asm index 8b1b5d7..010a099 100644 --- a/tools/tests/zasm/test4.asm +++ b/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