more work towards arrays
This commit is contained in:
1 parent
0f58b32b5b
commit
2126085899
2 files changed
+87
-15
No files matched your search
@@ -37,6 +37,8 @@ assign_variable:
|
|||||||
jsr is_var_ST
|
jsr is_var_ST
|
||||||
beq_16 do_SYNTAX_error
|
beq_16 do_SYNTAX_error
|
||||||
|
|
||||||
|
// XXX add support for arrays
|
||||||
|
|
||||||
// Retrieve the variable address
|
// Retrieve the variable address
|
||||||
|
|
||||||
jsr fetch_variable_find_addr
|
jsr fetch_variable_find_addr
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ fetch_variable_arr:
|
|||||||
!:
|
!:
|
||||||
// Fetch the 'coordinates'
|
// Fetch the 'coordinates'
|
||||||
|
|
||||||
|
lda FOUR6
|
||||||
|
pha // FOUR6 might get overridden, but we'll need it
|
||||||
|
|
||||||
ldx #$00 // counts number of dimensions
|
ldx #$00 // counts number of dimensions
|
||||||
|
|
||||||
// FALLTROUGH
|
// FALLTROUGH
|
||||||
@@ -74,6 +77,10 @@ fetch_variable_arr_check_dimensions:
|
|||||||
|
|
||||||
bne_16 do_BAD_SUBSCRIPT_error
|
bne_16 do_BAD_SUBSCRIPT_error
|
||||||
|
|
||||||
|
// Store number of dimensions, will be needed later
|
||||||
|
|
||||||
|
stx __FAC1+0
|
||||||
|
|
||||||
// FALLTROUGH
|
// FALLTROUGH
|
||||||
|
|
||||||
fetch_variable_arr_calc_pos:
|
fetch_variable_arr_calc_pos:
|
||||||
@@ -83,37 +90,100 @@ fetch_variable_arr_calc_pos:
|
|||||||
lda #$05
|
lda #$05
|
||||||
jsr helper_VARPNT_up_A
|
jsr helper_VARPNT_up_A
|
||||||
|
|
||||||
// Set previous dimension size as '1'
|
// Set the initial offset as '0'
|
||||||
|
|
||||||
// XXX implement this
|
lda #$00
|
||||||
|
sta __FAC1+1
|
||||||
|
sta __FAC1+2
|
||||||
|
|
||||||
// FALLTROUGH
|
// FALLTROUGH
|
||||||
|
|
||||||
fetch_variable_arr_calc_pos_loop:
|
fetch_variable_arr_calc_pos_loop:
|
||||||
|
|
||||||
// Fetch the coordinate from stack
|
// Fetch the current dimension
|
||||||
|
|
||||||
// XXX implement this
|
dex
|
||||||
|
txa
|
||||||
|
asl
|
||||||
|
tay
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
lda (VARPNT), y
|
||||||
|
sta __FAC1+3
|
||||||
|
iny
|
||||||
|
lda (VARPNT), y
|
||||||
|
sta __FAC1+4
|
||||||
|
iny
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Multiply offset by current dimension
|
||||||
|
|
||||||
|
jsr helper_array_create_mul
|
||||||
|
|
||||||
|
// Fetch the coordinate from stack; also add it to offset
|
||||||
|
|
||||||
|
clc
|
||||||
|
pla
|
||||||
|
sta INDEX+0
|
||||||
|
adc __FAC1+1
|
||||||
|
sta __FAC1+1
|
||||||
|
pla
|
||||||
|
sta INDEX+1
|
||||||
|
adc __FAC1+2
|
||||||
|
sta __FAC1+2
|
||||||
|
|
||||||
// Compare current coordinate with current dimension size
|
// Compare current coordinate with current dimension size
|
||||||
|
|
||||||
|
// XXX
|
||||||
// XXX implement this
|
// XXX implement this
|
||||||
|
// XXX
|
||||||
// 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
|
// Check if there are more dimensions to handle
|
||||||
|
|
||||||
dex
|
cpx #$00
|
||||||
bne fetch_variable_arr_calc_pos_loop
|
bne fetch_variable_arr_calc_pos_loop
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
fetch_variable_arr_calc_pos_loop_done:
|
||||||
|
|
||||||
|
// Retrieve FOUR6, use it to calculate final offset
|
||||||
|
|
||||||
|
pla
|
||||||
|
sta FOUR6 // XXX is it needed?
|
||||||
|
sta __FAC1+3
|
||||||
|
stx __FAC1+4 // .X is 0 at this moment
|
||||||
|
|
||||||
|
jsr helper_array_create_mul
|
||||||
|
|
||||||
|
// Increment VARPNT by number of dimensions * 2, to point start of data
|
||||||
|
|
||||||
|
lda __FAC1+0
|
||||||
|
asl
|
||||||
|
jsr helper_VARPNT_up_A
|
||||||
|
|
||||||
// Increment VARPNT by the calculated offset and quit
|
// Increment VARPNT by the calculated offset and quit
|
||||||
|
|
||||||
// XXX implement this
|
clc
|
||||||
|
lda __FAC1+1
|
||||||
|
adc VARPNT+0
|
||||||
|
sta VARPNT+0
|
||||||
|
lda __FAC1+2
|
||||||
|
adc VARPNT+1
|
||||||
|
sta VARPNT+1
|
||||||
|
|
||||||
jmp do_NOT_IMPLEMENTED_error
|
rts
|
||||||
Reference in new issue
Block a user