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
|
||||
|
||||
jsr fetch_variable
|
||||
bcs_16 do_SYNTAX_error
|
||||
jsr injest_assign
|
||||
bcs_16 do_SYNTAX_error
|
||||
|
||||
@@ -148,15 +149,35 @@ cmd_let_assign_string:
|
||||
|
||||
// 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: 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)
|
||||
|
||||
lda VARPNT+1
|
||||
lda VARPNT+0
|
||||
cmp __FAC1+1
|
||||
bne !+
|
||||
iny
|
||||
lda VARPNT+2
|
||||
lda VARPNT+1
|
||||
cmp __FAC1+2
|
||||
bne !+
|
||||
|
||||
|
||||
@@ -68,9 +68,19 @@ FRMEVL_loop:
|
||||
// $7F has to be a function
|
||||
|
||||
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
|
||||
@@ -279,7 +289,7 @@ FRMEVL_push_operator_address:
|
||||
// as this is the place where unary operator support calls
|
||||
|
||||
tsx
|
||||
cpx #$40 // XXX is this a safe threshold?
|
||||
cpx #$60 // XXX is this a safe threshold?
|
||||
bcc_16 do_FORMULA_TOO_COMPLEX_error
|
||||
|
||||
// Push the operator address to stack, in a form
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Carry set = failure, not recognized variable name
|
||||
//
|
||||
|
||||
|
||||
fetch_variable:
|
||||
|
||||
@@ -14,8 +18,17 @@ fetch_variable:
|
||||
|
||||
jsr fetch_character_skip_spaces
|
||||
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
|
||||
|
||||
// Fetch the (optional) second character
|
||||
@@ -96,7 +109,7 @@ fetch_variable_find_addr_loop:
|
||||
cmp ARYTAB+1
|
||||
bne !+
|
||||
lda VARPNT+0
|
||||
cmp VARPNT+0
|
||||
cmp ARYTAB+0
|
||||
beq fetch_variable_alocate
|
||||
!:
|
||||
// Compare current variable name with searched one
|
||||
@@ -151,6 +164,7 @@ fetch_variable_adjust_VARPNT:
|
||||
|
||||
#endif
|
||||
|
||||
clc
|
||||
rts
|
||||
|
||||
fetch_variable_find_addr_next:
|
||||
@@ -168,82 +182,87 @@ fetch_variable_find_addr_next:
|
||||
|
||||
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
|
||||
|
||||
// XXX
|
||||
// XXX: implement this
|
||||
// XXX
|
||||
sec
|
||||
lda FRETOP+0
|
||||
sbc STREND+0
|
||||
pha
|
||||
lda FRETOP+1
|
||||
sbc STREND+1
|
||||
bne !+ // branch if high byte of result > 0
|
||||
|
||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
// XXX consider optimized version without multiple JSRs
|
||||
pla
|
||||
cmp #$07
|
||||
bcs fetch_variable_alocate_space_OK
|
||||
|
||||
// XXX
|
||||
// XXX: implement this
|
||||
// XXX
|
||||
jmp do_OUT_OF_MEMORY_error
|
||||
!:
|
||||
pla
|
||||
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
// FALLTROUGH
|
||||
|
||||
// XXX
|
||||
// XXX: implement this
|
||||
// XXX
|
||||
|
||||
#endif
|
||||
fetch_variable_alocate_space_OK:
|
||||
|
||||
// If needed, move all the arrays up
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
|
||||
// XXX
|
||||
// XXX: implement this
|
||||
// XXX: implement this for arrays
|
||||
// XXX
|
||||
|
||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
// XXX consider optimized version without multiple JSRs
|
||||
|
||||
// XXX
|
||||
// XXX: implement this
|
||||
// XXX: implement this for arrays
|
||||
// XXX
|
||||
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
|
||||
// XXX
|
||||
// XXX: implement this
|
||||
// XXX: implement this for arrays
|
||||
// XXX
|
||||
|
||||
#endif
|
||||
|
||||
// Set pointer to new variable
|
||||
// Adjust ARYTAB and STREND
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
|
||||
// XXX
|
||||
// XXX: implement this
|
||||
// XXX
|
||||
clc
|
||||
lda STREND+0
|
||||
adc #$07
|
||||
sta STREND+0
|
||||
bcc !+
|
||||
inc STREND+1
|
||||
!:
|
||||
|
||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
// XXX consider optimized version without multiple JSRs
|
||||
|
||||
// XXX
|
||||
// XXX: implement this
|
||||
// XXX
|
||||
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
|
||||
// XXX
|
||||
// XXX: implement this
|
||||
// XXX
|
||||
|
||||
#endif
|
||||
clc
|
||||
lda ARYTAB+0
|
||||
adc #$07
|
||||
sta ARYTAB+0
|
||||
bcc !+
|
||||
inc ARYTAB+1
|
||||
!:
|
||||
// VARPNT already points to the start of the variable descriptor
|
||||
|
||||
// Fill-in the new variable name, descriptor (it is enough to zero first 2 bytes of content)
|
||||
|
||||
ldy #$00
|
||||
|
||||
#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
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
//
|
||||
|
||||
// XXX test this routine
|
||||
// XXX make it compatible with under-ROM routines
|
||||
// XXX change DSCPNT to use standard descriptor format
|
||||
|
||||
varstr_alloc:
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
// 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
|
||||
|
||||
sta DSCPNT+2
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
// XXX test this routine
|
||||
|
||||
// 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:
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
// 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
|
||||
|
||||
clc
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
// 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:
|
||||
|
||||
|
||||
Reference in new issue
Block a user