From 7243e417491f2b06e7dc82d2aae6f84bd803749e Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Thu, 25 Apr 2019 23:11:44 +0930 Subject: [PATCH] reject false positive matches on keywords --- c64/basic/basic_main_loop.s | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/c64/basic/basic_main_loop.s b/c64/basic/basic_main_loop.s index ea1b3056..e974ec36 100644 --- a/c64/basic/basic_main_loop.s +++ b/c64/basic/basic_main_loop.s @@ -78,7 +78,36 @@ next_in_match: dec tokenise_work4 ; Have we compared all bytes yet? bne next_in_match + ;; Keyword matches! + + ;; Now make sure we are on a keyword boundary. + ;; Offset 0 + ;; previous byte is $x0 + ;; two byte prior is $FE + + ;; Get offset of first byte of this token + ldx tokenise_work3 + dex ; pointer points one late, so rewind it + + ;; At start of list? + cpx #$00 + beq word_boundary + dex + ;; Previous byte is $x0 end token? + lda packed_keywords,x + and #$0f + beq word_boundary + dex + ;; Uber-previouss byte is $FE final literal token? + lda packed_keywords,x + cmp #$fe + beq word_boundary + + ;; Not a word boundary, so ignore + jmp next_kw_offset + +word_boundary: inc $d020 ;; We actually point one by late, so rewind to find start of token