more work towards arrays support

This commit is contained in:
FeralChild64 committed 2020-07-29 18:01:03 +02:00
1 parent 8769cc1657
commit 7e5cfe9d92
5 files changed
+129 -19

No files matched your search

@@ -5,8 +5,12 @@
check_stack_space:
phx_trash_a
tsx
cpx #$60 // XXX is this a safe threshold?
bcc_16 do_FORMULA_TOO_COMPLEX_error
plx_trash_a
rts
@@ -49,9 +49,7 @@ array_create_fetch_dims_loop:
// Check if the stack has reasonable space free
phx_trash_a
jsr check_stack_space
plx_trash_a
// Fetch the dimension, increment it by 1, and put it on the stack;
// confirmed with original ROM, that it also stores dimensions in the reverse order
+7 -14
View File
@@ -69,13 +69,9 @@ fetch_variable_adjust_VARPNT:
#if !HAS_OPCODES_65CE02
clc
lda VARPNT+0
adc #$02
sta VARPNT+0
bcc !+
inc VARPNT+1
!:
lda #$02
jsr helper_VARPNT_up_A
#else // HAS_OPCODES_65CE02
inw VARPNT
@@ -91,13 +87,10 @@ fetch_variable_find_addr_next:
// Increase VARPNT by 7 - constant value, each variable uses 7 bytes, see:
// - https://sites.google.com/site/h2obsession/CBM/basic/variable-format
clc
lda VARPNT+0
adc #$07
sta VARPNT+0
bcc fetch_variable_find_addr_loop
inc VARPNT+1
bne fetch_variable_find_addr_loop // branch always
lda #$07
jsr helper_VARPNT_up_A
jmp_8 fetch_variable_find_addr_loop
fetch_variable_alocate:
+100 -3
View File
@@ -10,13 +10,110 @@ fetch_variable_arr:
// Array does not exist - we will have to create one with default parameters
lda #$00
sta VARPNT+1
// XXX implement this
jmp do_NOT_IMPLEMENTED_error
!:
// Fetch the 'coordinates'
ldx #$00 // counts number of dimensions
// FALLTROUGH
fetch_variable_arr_fetch_coords_loop:
inx
// Check if the stack has reasonable space free
jsr check_stack_space
// Fetch the dimension and put it on the stack
jsr fetch_uint16
bcs_16 do_SYNTAX_error
lda LINNUM+0
pha
lda LINNUM+1
pha
// Check if more dimensions are given
jsr fetch_character_skip_spaces
cmp #$2C // ','
beq fetch_variable_arr_fetch_coords_loop
cmp #$29 // ')'
bne_16 do_SYNTAX_error
// FALLTROUGH
fetch_variable_arr_check_dimensions:
// Check if the number of dimensions matches the stored ones
#if CONFIG_MEMORY_MODEL_60K
// XXX
// XXX
// XXX
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
// XXX
// XXX
// XXX
#else // CONFIG_MEMORY_MODEL_38
ldy #$04
txa
cmp (VARPNT), y
#endif
bne_16 do_BAD_SUBSCRIPT_error
// FALLTROUGH
fetch_variable_arr_calc_pos:
// Move VARPNT po point to sizes in each dimension
lda #$05
jsr helper_VARPNT_up_A
// Set previous dimension size as '1'
// XXX implement this
// XXX finish the implementation
// FALLTROUGH
fetch_variable_arr_calc_pos_loop:
// Fetch the coordinate from stack
// XXX implement this
// Compare current coordinate with current dimension size
// XXX implement this
// Multiply current coordinate with previous dimension
// XXX implement this
// Store current dimension, for the next iteration
// XXX implement this
// Check if there are more dimensions to handle
dex
bne fetch_variable_arr_calc_pos_loop
// Increment VARPNT by the calculated offset and quit
// XXX implement this
jmp do_NOT_IMPLEMENTED_error
@@ -0,0 +1,18 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Helper routine, used by various variable-related routines
//
helper_VARPNT_up_A: // .A - bytes to increment VARPNT
clc
adc VARPNT+0
sta VARPNT+0
bcc !+
inc VARPNT+1
!:
rts