From 3bdfa8f834a0850d1f1d0edf2c3b7984b2f9778b Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Mon, 29 Apr 2019 22:25:03 +0930 Subject: [PATCH] make injest_number work from current basic statement pointer --- c64/basic/basic_main_loop.s | 11 ++++++++++- c64/basic/injest_number.s | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/c64/basic/basic_main_loop.s b/c64/basic/basic_main_loop.s index 5f01837e..60909d0e 100644 --- a/c64/basic/basic_main_loop.s +++ b/c64/basic/basic_main_loop.s @@ -78,9 +78,18 @@ rsl_l1: lda $0200,x sta tokenise_work2 lda #$00 sta tokenise_work1 - + + ;; Try to read linne number + lda #<$0200 + sta basic_current_statement_ptr+0 + lda #>$0200 + sta basic_current_statement_ptr+1 jsr injest_number + ;; Copy offset of first position after number back out + lda basic_current_statement_ptr+0 + sta tokenise_work1 + ;; Check if the number is a valid line number ;; i.e., 16 bits, no exponent, no decimal lda basic_fac1_mantissa+2 diff --git a/c64/basic/injest_number.s b/c64/basic/injest_number.s index d53af006..947d7d89 100644 --- a/c64/basic/injest_number.s +++ b/c64/basic/injest_number.s @@ -1,6 +1,6 @@ - ;; Parse a number from the input buffer at $0200+tokenise_work1 + ;; Parse a number from the input buffer at (basic_current_statement_ptr) ;; Result is put into FAC1. - ;; tokenise_work1 is updated with first position after the number. + ;; basic_current_statement_ptr is updated with first position after the number. ;; XXX - Remember decimal position and exponent, and apply them ;; after to produce normalised floating point number. @@ -51,8 +51,8 @@ injest_number: ;; Check if leading char is a - sign ;; Note: the - will have been tokenised to $AB ;; XXX - implement - ldx tokenise_work1 - lda $0200,x + ldy #$00 + lda (basic_current_statement_ptr),y cmp #$AB bne ij_not_minus @@ -63,9 +63,9 @@ injest_number: ij_not_minus: -ij_loop1: - ldx tokenise_work1 - lda $0200,x +ij_loop1: + ldy #$00 + lda (basic_current_statement_ptr),y cmp #$30 bcc ij_not_a_digit cmp #$39 @@ -102,8 +102,8 @@ ij_accept_precision: bne ij_consider_next_digit ;; Get digit - ldx tokenise_work1 - lda $0200,x + ldy #$00 + lda (basic_current_statement_ptr),y sec sbc #$30 @@ -131,7 +131,7 @@ ij_loop2: ij_consider_next_digit: ;; Consider next digit - inc tokenise_work1 + jsr basic_consume_character jmp ij_loop1 rts