work on getting BASIC line number entry working.
This commit is contained in:
1 parent
bd4af88e02
commit
eef572e0ab
8 files changed
+123
-5
No files matched your search
@@ -6,6 +6,7 @@
|
|||||||
.alias tokenise_work2 $8
|
.alias tokenise_work2 $8
|
||||||
.alias tokenise_work3 $B
|
.alias tokenise_work3 $B
|
||||||
.alias tokenise_work4 $F
|
.alias tokenise_work4 $F
|
||||||
|
.alias basic_line_number $14
|
||||||
.alias temp_string_ptr $35
|
.alias temp_string_ptr $35
|
||||||
.alias load_or_verify_or_tokenise_work5 $C
|
.alias load_or_verify_or_tokenise_work5 $C
|
||||||
.alias basic_work22 $22
|
.alias basic_work22 $22
|
||||||
@@ -13,6 +14,18 @@
|
|||||||
.alias basic_work24 $24
|
.alias basic_work24 $24
|
||||||
.alias basic_work25 $25
|
.alias basic_work25 $25
|
||||||
|
|
||||||
|
;; The various pointers that separate memory regions for BASIC storage
|
||||||
|
;; We have multiple names for the ones that mark the boundary of regions.
|
||||||
|
.alias basic_start_of_text_ptr $2b
|
||||||
|
.alias basic_end_of_text_ptr $2d
|
||||||
|
.alias basic_start_of_vars_ptr $2d
|
||||||
|
.alias basic_end_of_vars_ptr $2f
|
||||||
|
.alias basic_start_of_arrays_ptr $2f
|
||||||
|
.alias basic_end_of_arrays_ptr $31
|
||||||
|
.alias basic_start_of_free_space_ptr $31
|
||||||
|
.alias basic_start_of_strings_ptr $33
|
||||||
|
.alias basic_top_of_memory_ptr $35
|
||||||
|
|
||||||
.alias basic_numeric_work_area $57 ; $57 - $60 inclusive = 10 bytes
|
.alias basic_numeric_work_area $57 ; $57 - $60 inclusive = 10 bytes
|
||||||
|
|
||||||
;; Floating point accumulator 1 $61 - $68
|
;; Floating point accumulator 1 $61 - $68
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ basic_cold_start:
|
|||||||
ldx #34
|
ldx #34
|
||||||
jsr print_packed_message
|
jsr print_packed_message
|
||||||
|
|
||||||
|
jsr basic_do_new
|
||||||
|
|
||||||
;; jump into warm start loop
|
;; jump into warm start loop
|
||||||
jmp basic_warm_start
|
jmp basic_warm_start
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,13 @@ basic_main_loop:
|
|||||||
;; the appropriate way.
|
;; the appropriate way.
|
||||||
;; XXX - For now, it is hard coded to direct mode
|
;; XXX - For now, it is hard coded to direct mode
|
||||||
|
|
||||||
|
;; Tell user we are ready
|
||||||
|
jsr ready_message
|
||||||
|
|
||||||
;; Read a line of input
|
;; Read a line of input
|
||||||
ldx #$00
|
ldx #$00
|
||||||
read_line_loop:
|
read_line_loop:
|
||||||
|
|
||||||
jsr $ffcf ; KERNAL CHRIN
|
jsr $ffcf ; KERNAL CHRIN
|
||||||
bcs read_line_loop
|
bcs read_line_loop
|
||||||
|
|
||||||
@@ -74,9 +78,32 @@ rsl_l1: lda $0200,x
|
|||||||
lda tokenise_work1
|
lda tokenise_work1
|
||||||
sta $0427
|
sta $0427
|
||||||
|
|
||||||
|
;; Check if the number is a valid line number
|
||||||
|
;; i.e., 16 bits, no exponent, no decimal
|
||||||
|
lda basic_fac1_mantissa+2
|
||||||
|
ora basic_fac1_mantissa+3
|
||||||
|
ora basic_fac1_exponent
|
||||||
|
beq +
|
||||||
|
ml_bad_line_number:
|
||||||
|
;; Syntax error
|
||||||
|
ldx #10
|
||||||
|
jmp do_basic_error
|
||||||
|
* lda tokenise_work4
|
||||||
|
cmp #$ff
|
||||||
|
beq ml_bad_line_number
|
||||||
|
|
||||||
|
;; Got a valid line number.
|
||||||
|
|
||||||
|
;; Copy to line number holder
|
||||||
|
lda basic_fac1_mantissa+0
|
||||||
|
sta basic_line_number+0
|
||||||
|
lda basic_fac1_mantissa+1
|
||||||
|
sta basic_line_number+1
|
||||||
|
|
||||||
|
;; Delete line if present
|
||||||
|
|
||||||
|
;; Insert new line if non-zero length
|
||||||
|
|
||||||
not_a_line:
|
not_a_line:
|
||||||
|
|
||||||
jsr ready_message
|
|
||||||
|
|
||||||
jmp basic_main_loop
|
jmp basic_main_loop
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
;; Clear screen etc, show READY prompt.
|
;; Clear screen etc, show READY prompt.
|
||||||
|
|
||||||
basic_warm_start:
|
basic_warm_start:
|
||||||
jsr ready_message
|
|
||||||
jmp basic_main_loop
|
jmp basic_main_loop
|
||||||
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
cmd_new:
|
||||||
|
jsr basic_do_new
|
||||||
|
jmp basic_main_loop
|
||||||
|
|
||||||
|
cmd_clr:
|
||||||
|
jsr basic_do_clr
|
||||||
|
jmp basic_main_loop
|
||||||
|
|
||||||
|
basic_do_new:
|
||||||
|
;; Setup pointers to memory storage
|
||||||
|
lda #<$0801
|
||||||
|
sta basic_start_of_text_ptr+0
|
||||||
|
lda >$0801
|
||||||
|
sta basic_start_of_text_ptr+1
|
||||||
|
sta basic_start_of_vars_ptr+1
|
||||||
|
lda #<$0803
|
||||||
|
sta basic_start_of_vars_ptr+0
|
||||||
|
|
||||||
|
;; FALL THROUGH
|
||||||
|
|
||||||
|
basic_do_clr:
|
||||||
|
;; Clear variables, arrays and strings
|
||||||
|
lda basic_start_of_vars_ptr+0
|
||||||
|
sta basic_start_of_arrays_ptr+0
|
||||||
|
sta basic_start_of_free_space_ptr+0
|
||||||
|
lda basic_start_of_vars_ptr+1
|
||||||
|
sta basic_start_of_arrays_ptr+1
|
||||||
|
sta basic_start_of_free_space_ptr+1
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
@@ -4,6 +4,8 @@ do_basic_error:
|
|||||||
;; "?"
|
;; "?"
|
||||||
txa
|
txa
|
||||||
pha
|
pha
|
||||||
|
lda #$0d
|
||||||
|
jsr $ffd2
|
||||||
lda #$3f
|
lda #$3f
|
||||||
jsr $ffd2
|
jsr $ffd2
|
||||||
pla
|
pla
|
||||||
@@ -12,6 +14,7 @@ do_basic_error:
|
|||||||
;; Error message text
|
;; Error message text
|
||||||
jsr print_packed_message
|
jsr print_packed_message
|
||||||
|
|
||||||
|
;; A space between error name and word error
|
||||||
lda #$20
|
lda #$20
|
||||||
jsr $ffd2
|
jsr $ffd2
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ f1m10_l3:
|
|||||||
;; All done, return
|
;; All done, return
|
||||||
clc
|
clc
|
||||||
rts
|
rts
|
||||||
|
*
|
||||||
;; Divide mantissa by two, and increment exponent
|
;; Divide mantissa by two, and increment exponent
|
||||||
jsr fac1_mantissa_div2
|
jsr fac1_mantissa_div2
|
||||||
inc basic_fac1_exponent
|
inc basic_fac1_exponent
|
||||||
|
|||||||
@@ -6,8 +6,38 @@
|
|||||||
;; after to produce normalised floating point number.
|
;; after to produce normalised floating point number.
|
||||||
|
|
||||||
ij_not_a_digit:
|
ij_not_a_digit:
|
||||||
;; XXX check for ".", "E", "+" and "-"
|
;; XXX check for "." or "E"
|
||||||
;; Other chars terminate the accumulation.
|
;; Other chars terminate the accumulation.
|
||||||
|
|
||||||
|
;; Look for exponentiation marker
|
||||||
|
;; XXX - Implement me!
|
||||||
|
;; Probably should have a flag so that we know if we are accumulating
|
||||||
|
;; exponent or mantissa digits
|
||||||
|
|
||||||
|
;; Look for decimal point
|
||||||
|
sta $0420
|
||||||
|
cmp #$2e
|
||||||
|
bne ij_not_decimal
|
||||||
|
lda tokenise_work4
|
||||||
|
cmp #$ff
|
||||||
|
beq ij_found_decimal
|
||||||
|
;; More than one decimal point in a number means we have reached the end of the number
|
||||||
|
clc
|
||||||
|
rts
|
||||||
|
|
||||||
|
ij_found_decimal:
|
||||||
|
;; Found decimal.
|
||||||
|
;; Thus start counting digits after the decimal, so that we
|
||||||
|
;; can do the necessary number of divide by 10s on the final
|
||||||
|
;; number.
|
||||||
|
lda #$00
|
||||||
|
sta tokenise_work4
|
||||||
|
|
||||||
|
jmp ij_consider_next_digit
|
||||||
|
|
||||||
|
ij_not_decimal:
|
||||||
|
|
||||||
|
|
||||||
CLC
|
CLC
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@@ -22,6 +52,17 @@ injest_number:
|
|||||||
;; Check if leading char is a - sign
|
;; Check if leading char is a - sign
|
||||||
;; Note: the - will have been tokenised to $AB
|
;; Note: the - will have been tokenised to $AB
|
||||||
;; XXX - implement
|
;; XXX - implement
|
||||||
|
ldx tokenise_work1
|
||||||
|
lda $0200,x
|
||||||
|
cmp #$AB
|
||||||
|
bne ij_not_minus
|
||||||
|
|
||||||
|
;; Set sign to negative
|
||||||
|
lda #$ff
|
||||||
|
sta basic_fac1_sign
|
||||||
|
|
||||||
|
ij_not_minus:
|
||||||
|
|
||||||
|
|
||||||
ij_loop1:
|
ij_loop1:
|
||||||
ldx tokenise_work1
|
ldx tokenise_work1
|
||||||
|
|||||||
Reference in new issue
Block a user