string handling fixes
This commit is contained in:
1 parent
26ce9d3b58
commit
127b71f67f
8 files changed
+107
-53
No files matched your search
@@ -9,6 +9,7 @@ cmd_let:
|
|||||||
// Fetch variable name, should be followed by assign operator
|
// Fetch variable name, should be followed by assign operator
|
||||||
|
|
||||||
jsr fetch_variable
|
jsr fetch_variable
|
||||||
|
bcs_16 do_SYNTAX_error
|
||||||
jsr injest_assign
|
jsr injest_assign
|
||||||
bcs_16 do_SYNTAX_error
|
bcs_16 do_SYNTAX_error
|
||||||
|
|
||||||
@@ -148,15 +149,35 @@ cmd_let_assign_string:
|
|||||||
|
|
||||||
// First special case - check if the new string has size 0
|
// First special case - check if the new string has size 0
|
||||||
|
|
||||||
|
lda DSCPNT+0
|
||||||
|
bne cmd_let_assign_string_not_empty
|
||||||
|
|
||||||
|
// XXX free old string data
|
||||||
|
|
||||||
|
// Set the new variable as size 0
|
||||||
|
|
||||||
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
|
|
||||||
// XXX
|
// XXX
|
||||||
|
// XXX: implement this
|
||||||
|
// XXX
|
||||||
|
|
||||||
|
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
cmd_let_assign_string_not_empty:
|
||||||
|
|
||||||
// Check if the source and destination strings are the same (VARPNT should now point just after variable name)
|
// Check if the source and destination strings are the same (VARPNT should now point just after variable name)
|
||||||
|
|
||||||
lda VARPNT+1
|
lda VARPNT+0
|
||||||
cmp __FAC1+1
|
cmp __FAC1+1
|
||||||
bne !+
|
bne !+
|
||||||
iny
|
iny
|
||||||
lda VARPNT+2
|
lda VARPNT+1
|
||||||
cmp __FAC1+2
|
cmp __FAC1+2
|
||||||
bne !+
|
bne !+
|
||||||
|
|
||||||
|
|||||||
@@ -68,9 +68,19 @@ FRMEVL_loop:
|
|||||||
// $7F has to be a function
|
// $7F has to be a function
|
||||||
|
|
||||||
cmp #$80 // check for a token
|
cmp #$80 // check for a token
|
||||||
bcc FRMEVL_execute_function
|
bcs FRMEVL_execute_function
|
||||||
|
|
||||||
// There are 2 possibilities left - a floating point value or a variable
|
// Check for a variable
|
||||||
|
|
||||||
|
#if !HAS_OPCODES_65CE02
|
||||||
|
jsr unconsume_character
|
||||||
|
#else
|
||||||
|
dew TXTPTR
|
||||||
|
#endif
|
||||||
|
jsr fetch_variable
|
||||||
|
bcc FRMEVL_got_value
|
||||||
|
|
||||||
|
// There is one possibility left - a floating point value
|
||||||
|
|
||||||
|
|
||||||
// XXX implement this part
|
// XXX implement this part
|
||||||
@@ -279,7 +289,7 @@ FRMEVL_push_operator_address:
|
|||||||
// as this is the place where unary operator support calls
|
// as this is the place where unary operator support calls
|
||||||
|
|
||||||
tsx
|
tsx
|
||||||
cpx #$40 // XXX is this a safe threshold?
|
cpx #$60 // XXX is this a safe threshold?
|
||||||
bcc_16 do_FORMULA_TOO_COMPLEX_error
|
bcc_16 do_FORMULA_TOO_COMPLEX_error
|
||||||
|
|
||||||
// Push the operator address to stack, in a form
|
// Push the operator address to stack, in a form
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
// #LAYOUT# * BASIC_0 #TAKE
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
// #LAYOUT# * * #IGNORE
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
//
|
||||||
|
// Carry set = failure, not recognized variable name
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
fetch_variable:
|
fetch_variable:
|
||||||
|
|
||||||
@@ -14,8 +18,17 @@ fetch_variable:
|
|||||||
|
|
||||||
jsr fetch_character_skip_spaces
|
jsr fetch_character_skip_spaces
|
||||||
jsr is_AZ
|
jsr is_AZ
|
||||||
bcs_16 do_SYNTAX_error
|
bcc !+
|
||||||
|
|
||||||
|
#if !HAS_OPCODES_65CE02
|
||||||
|
jsr unconsume_character
|
||||||
|
#else
|
||||||
|
dew TXTPTR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
sec
|
||||||
|
rts
|
||||||
|
!:
|
||||||
sta VARNAM+0
|
sta VARNAM+0
|
||||||
|
|
||||||
// Fetch the (optional) second character
|
// Fetch the (optional) second character
|
||||||
@@ -96,7 +109,7 @@ fetch_variable_find_addr_loop:
|
|||||||
cmp ARYTAB+1
|
cmp ARYTAB+1
|
||||||
bne !+
|
bne !+
|
||||||
lda VARPNT+0
|
lda VARPNT+0
|
||||||
cmp VARPNT+0
|
cmp ARYTAB+0
|
||||||
beq fetch_variable_alocate
|
beq fetch_variable_alocate
|
||||||
!:
|
!:
|
||||||
// Compare current variable name with searched one
|
// Compare current variable name with searched one
|
||||||
@@ -151,6 +164,7 @@ fetch_variable_adjust_VARPNT:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
clc
|
||||||
rts
|
rts
|
||||||
|
|
||||||
fetch_variable_find_addr_next:
|
fetch_variable_find_addr_next:
|
||||||
@@ -168,82 +182,87 @@ fetch_variable_find_addr_next:
|
|||||||
|
|
||||||
fetch_variable_alocate:
|
fetch_variable_alocate:
|
||||||
|
|
||||||
// First check if we have enough space for a new descriptor
|
// First check if we have enough space for a new descriptor (if FRETOP - STREND >= 7)
|
||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
sec
|
||||||
|
lda FRETOP+0
|
||||||
// XXX
|
sbc STREND+0
|
||||||
// XXX: implement this
|
pha
|
||||||
// XXX
|
lda FRETOP+1
|
||||||
|
sbc STREND+1
|
||||||
|
bne !+ // branch if high byte of result > 0
|
||||||
|
|
||||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
pla
|
||||||
// XXX consider optimized version without multiple JSRs
|
cmp #$07
|
||||||
|
bcs fetch_variable_alocate_space_OK
|
||||||
|
|
||||||
// XXX
|
jmp do_OUT_OF_MEMORY_error
|
||||||
// XXX: implement this
|
!:
|
||||||
// XXX
|
pla
|
||||||
|
|
||||||
#else // CONFIG_MEMORY_MODEL_38K
|
// FALLTROUGH
|
||||||
|
|
||||||
// XXX
|
fetch_variable_alocate_space_OK:
|
||||||
// XXX: implement this
|
|
||||||
// XXX
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// If needed, move all the arrays up
|
// If needed, move all the arrays up
|
||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
|
|
||||||
// XXX
|
// XXX
|
||||||
// XXX: implement this
|
// XXX: implement this for arrays
|
||||||
// XXX
|
// XXX
|
||||||
|
|
||||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||||
// XXX consider optimized version without multiple JSRs
|
// XXX consider optimized version without multiple JSRs
|
||||||
|
|
||||||
// XXX
|
// XXX
|
||||||
// XXX: implement this
|
// XXX: implement this for arrays
|
||||||
// XXX
|
// XXX
|
||||||
|
|
||||||
#else // CONFIG_MEMORY_MODEL_38K
|
#else // CONFIG_MEMORY_MODEL_38K
|
||||||
|
|
||||||
// XXX
|
// XXX
|
||||||
// XXX: implement this
|
// XXX: implement this for arrays
|
||||||
// XXX
|
// XXX
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set pointer to new variable
|
// Adjust ARYTAB and STREND
|
||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
clc
|
||||||
|
lda STREND+0
|
||||||
// XXX
|
adc #$07
|
||||||
// XXX: implement this
|
sta STREND+0
|
||||||
// XXX
|
bcc !+
|
||||||
|
inc STREND+1
|
||||||
|
!:
|
||||||
|
|
||||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
clc
|
||||||
// XXX consider optimized version without multiple JSRs
|
lda ARYTAB+0
|
||||||
|
adc #$07
|
||||||
// XXX
|
sta ARYTAB+0
|
||||||
// XXX: implement this
|
bcc !+
|
||||||
// XXX
|
inc ARYTAB+1
|
||||||
|
!:
|
||||||
#else // CONFIG_MEMORY_MODEL_38K
|
// VARPNT already points to the start of the variable descriptor
|
||||||
|
|
||||||
// XXX
|
|
||||||
// XXX: implement this
|
|
||||||
// XXX
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Fill-in the new variable name, descriptor (it is enough to zero first 2 bytes of content)
|
// Fill-in the new variable name, descriptor (it is enough to zero first 2 bytes of content)
|
||||||
|
|
||||||
ldy #$00
|
ldy #$00
|
||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
|
|
||||||
// XXX
|
ldx #<VARNAM
|
||||||
|
lda VARNAM+0
|
||||||
|
jsr poke_under_roms
|
||||||
|
iny
|
||||||
|
lda VARNAM+1
|
||||||
|
jsr poke_under_roms
|
||||||
|
iny
|
||||||
|
lda #$00
|
||||||
|
jsr poke_under_roms
|
||||||
|
iny
|
||||||
|
jsr poke_under_roms
|
||||||
|
|
||||||
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
// XXX test this routine
|
// XXX test this routine
|
||||||
// XXX make it compatible with under-ROM routines
|
// XXX change DSCPNT to use standard descriptor format
|
||||||
|
|
||||||
varstr_alloc:
|
varstr_alloc:
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
// Helper routines for 'varstr_alloc'
|
// Helper routines for 'varstr_alloc'
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// XXX change DSCPNT to use standard descriptor format
|
||||||
|
|
||||||
varstr_FRETOP_down_A: // .A - bytes to lower FRETOP, uses DSCPNT+2
|
varstr_FRETOP_down_A: // .A - bytes to lower FRETOP, uses DSCPNT+2
|
||||||
|
|
||||||
sta DSCPNT+2
|
sta DSCPNT+2
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
// XXX test this routine
|
// XXX test this routine
|
||||||
|
|
||||||
// XXX handle strings located in program area
|
// XXX handle strings located in program area
|
||||||
// XXX change DSCPNT format to be compliant with all other descriptors
|
|
||||||
|
// XXX change DSCPNT to use standard descriptor format
|
||||||
|
|
||||||
varstr_free:
|
varstr_free:
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
// Helper routines for 'varstr_free'
|
// Helper routines for 'varstr_free'
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// XXX change DSCPNT to use standard descriptor format
|
||||||
|
|
||||||
varstr_FRETOP_up: // DSCPNT+2 - bytes to increment FRETO, uses DSCPNT+2
|
varstr_FRETOP_up: // DSCPNT+2 - bytes to increment FRETO, uses DSCPNT+2
|
||||||
|
|
||||||
clc
|
clc
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
|
|
||||||
// XXX test this routine
|
// XXX test this routine
|
||||||
|
|
||||||
// XXX change DSCPNT format to be compliant with all other descriptors
|
// XXX change DSCPNT to use standard descriptor format
|
||||||
|
|
||||||
|
|
||||||
varstr_garbage_collect:
|
varstr_garbage_collect:
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user