From 04e5dd326f21656283806145fcfd3c2a87c395fe Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Thu, 25 Apr 2019 22:37:00 +0930 Subject: [PATCH] fix some problems with token searching --- c64/basic/basic_main_loop.s | 6 ++++++ c64/basic/pack_word.s | 13 +++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/c64/basic/basic_main_loop.s b/c64/basic/basic_main_loop.s index 719ed601..0798111a 100644 --- a/c64/basic/basic_main_loop.s +++ b/c64/basic/basic_main_loop.s @@ -80,11 +80,17 @@ next_in_match: ;; Keyword matches! inc $d020 tya + + ;; We actually point one by late, so rewind to find start of token + lda tokenise_work3 + sec + sbc #$01 clc adc #packed_keywords sta temp_string_ptr+1 + ;; Print the token we found jsr print_packed_string done_searching_for_token: diff --git a/c64/basic/pack_word.s b/c64/basic/pack_word.s index 83559a9f..7f0ad60a 100644 --- a/c64/basic/pack_word.s +++ b/c64/basic/pack_word.s @@ -91,8 +91,7 @@ write_literal_and_terminate_if_required: lda $0200,x jsr write_unpacked_char - jsr end_string_if_required - jmp consider_next_char + jmp end_string_if_required end_string_if_required: ;; Check if X points to last char of string to be packed @@ -100,7 +99,7 @@ end_string_if_required: cpx tokenise_work1 beq + dex - rts + jmp consider_next_char * dex ;; Fall through @@ -154,10 +153,8 @@ stored_nybl: inc tokenise_work2 ;; Add termination byte if required - ;; (This re-writes the same byte again, which we don't care about - jsr end_string_if_required - - jmp consider_next_char + ;; (This re-writes the same byte again, which we don't care about) + jmp end_string_if_required whole_byte_symbol: ;; It's a $Fx symbol. @@ -181,7 +178,7 @@ nothing_to_flush: ;; if it has been passed to us via fall-through jsr write_unpacked_char - jsr end_string_if_required + jmp end_string_if_required consider_next_char: ;; Pack next char