From 21c49d80cfc22a61956b0f0ffcb52288566ed2b2 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Fri, 17 May 2019 17:22:16 -0400 Subject: [PATCH] zasm: allow single quote to contain whitespace --- apps/zasm/tok.asm | 21 +++++++++++++++++++-- tools/tests/zasm/test4.asm | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/apps/zasm/tok.asm b/apps/zasm/tok.asm index 82f5493..99e4e61 100644 --- a/apps/zasm/tok.asm +++ b/apps/zasm/tok.asm @@ -92,10 +92,12 @@ 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. + ; Are we opening a double quote? cp '"' jr z, .insideQuote + ; Are we opening a single quote? + cp 0x27 ; ' + jr z, .singleQuote .loop2: ld (hl), a inc hl @@ -134,6 +136,21 @@ readWord: djnz .insideQuote ; out of space. 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, ; 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 010a099..3fd6852 100644 --- a/tools/tests/zasm/test4.asm +++ b/tools/tests/zasm/test4.asm @@ -5,5 +5,6 @@ ld a, 0x42 ld hl, 0x4234 ld hl, (0x4234) ld a, 'X' +ld a, ' ' ld a, 'a' ; don't upcase! .db "bonjour allo", 0