From 249266232cb3ef141ca6d22d1e473fc5881a491f Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Sun, 28 Apr 2019 21:50:52 +0930 Subject: [PATCH] begin implementing framework for interpreting BASIC statements. --- c64/basic/,aliases.s | 5 +++++ c64/basic/basic_execute_line.s | 11 +++++++++++ c64/basic/basic_main_loop.s | 29 ++++++++++++++++++++++++++--- 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 c64/basic/basic_execute_line.s diff --git a/c64/basic/,aliases.s b/c64/basic/,aliases.s index b0b572b1..706116de 100644 --- a/c64/basic/,aliases.s +++ b/c64/basic/,aliases.s @@ -25,7 +25,12 @@ .alias basic_start_of_free_space_ptr $31 .alias basic_start_of_strings_ptr $33 .alias basic_top_of_memory_ptr $37 + .alias basic_current_line_number $39 .alias basic_current_line_ptr $3d + + ;; Note that the statement point is in the CHRGET/CHRGOT routine + ;; in ZP RAM. (Compute's Mapping the 64, p25) + .alias basic_current_statement_ptr $7a .alias basic_numeric_work_area $57 ; $57 - $60 inclusive = 10 bytes diff --git a/c64/basic/basic_execute_line.s b/c64/basic/basic_execute_line.s new file mode 100644 index 00000000..12c33f00 --- /dev/null +++ b/c64/basic/basic_execute_line.s @@ -0,0 +1,11 @@ + ;; Go through the line until its end is reached. + ;; If we reach the end are in direct mode, then + ;; go back to reading input, else look for the + ;; next line, and advance to that, or else + ;; return to READY prompt because we have run out + ;; of program. + +basic_execute_line: + + + jmp basic_main_loop diff --git a/c64/basic/basic_main_loop.s b/c64/basic/basic_main_loop.s index ba1e780d..5f01837e 100644 --- a/c64/basic/basic_main_loop.s +++ b/c64/basic/basic_main_loop.s @@ -54,6 +54,11 @@ rsl_l1: lda $0200,x lda #$0d jsr $ffd2 + ;; Ignore empty lines + lda tokenise_work1 + beq basic_read_next_line + + ;; Else, tokenise the line jsr tokenise_line ;; Has the user entered a line of BASIC beginning with a number? @@ -135,6 +140,24 @@ skip_spaces: not_a_line: - ;; XXX - Actually interpret the line - - jmp basic_main_loop + ;; Actually interpret the line + + ;; Setup pointer to the statement + lda #<$0200 + sta basic_current_statement_ptr+0 + lda #>$0200 + sta basic_current_statement_ptr+1 + + ;; There is no stored line, so zero that pointer out + lda #$00 + sta basic_current_line_ptr+0 + sta basic_current_line_ptr+1 + + ;; Put invalid line number in current line number value, + ;; so that we know we are in direct mode + ;; (Compute's Mapping the 64 p19) + lda #$ff + sta basic_current_line_number+1 + + jmp basic_execute_line +