string assignment can sometimes reuse old string alocated memory
This commit is contained in:
1 parent
60f30f22fb
commit
c50595ab2d
4 files changed
+97
-59
No files matched your search
@@ -259,24 +259,41 @@ cmd_let_assign_string_not_same:
|
|||||||
|
|
||||||
cmd_let_assign_string_not_text_area:
|
cmd_let_assign_string_not_text_area:
|
||||||
|
|
||||||
// Check if size of both strings equals and the old on is above FRETOP
|
// Check if the new string is a temporary one - if so, reuse alocation
|
||||||
|
|
||||||
// XXX
|
// XXX
|
||||||
|
|
||||||
// Check if new one is at least 3 bytes shorter and the old one is above FRETOP
|
// Check if the old string belongs to the string area (is above FRETOP)
|
||||||
|
|
||||||
// XXX
|
jsr varstr_cmp_fretop
|
||||||
|
bcc cmd_let_assign_string_no_optimizations
|
||||||
|
|
||||||
// Check if the new string is a temporary one - if so, reuse already done alocation
|
// FALLTROUGH
|
||||||
|
|
||||||
// XXX
|
cmd_let_assign_string_try_reuse:
|
||||||
|
|
||||||
// No special case optimization is possible
|
// Check if size of both strings equals
|
||||||
// Free the memory belonging to the old string
|
|
||||||
|
lda DSCPNT+0
|
||||||
|
cmp __FAC1
|
||||||
|
bne cmd_let_assign_string_try_reuse_unsuccesful
|
||||||
|
|
||||||
|
// Size of both string equals, the old one belongs to the string area - simply reuse it
|
||||||
|
|
||||||
|
jmp helper_let_strvarcpy
|
||||||
|
|
||||||
|
cmd_let_assign_string_try_reuse_unsuccesful:
|
||||||
|
// XXX consider another optimization first: parial memory reuse
|
||||||
|
|
||||||
|
// No special case optimization is possible - but first get rid of the old string
|
||||||
|
|
||||||
jsr varstr_free
|
jsr varstr_free
|
||||||
|
|
||||||
// And allocate memory for the new string
|
// FALLTROUGH
|
||||||
|
|
||||||
|
cmd_let_assign_string_no_optimizations:
|
||||||
|
|
||||||
|
// Allocate memory for the new string
|
||||||
|
|
||||||
lda __FAC1+0
|
lda __FAC1+0
|
||||||
ldy #$00
|
ldy #$00
|
||||||
@@ -294,55 +311,6 @@ cmd_let_assign_string_not_text_area:
|
|||||||
|
|
||||||
jsr varstr_alloc
|
jsr varstr_alloc
|
||||||
|
|
||||||
// Copy the string
|
// Copy the string and quit
|
||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
jmp helper_let_strvarcpy
|
||||||
|
|
||||||
ldx #<VARPNT
|
|
||||||
|
|
||||||
ldy #$02
|
|
||||||
jsr peek_under_roms
|
|
||||||
sta DSCPNT+2
|
|
||||||
dey
|
|
||||||
jsr peek_under_roms
|
|
||||||
sta DSCPNT+1
|
|
||||||
dey
|
|
||||||
|
|
||||||
// .Y is now 0 - copy the content
|
|
||||||
!:
|
|
||||||
|
|
||||||
ldx #<__FAC1+1
|
|
||||||
jsr peek_under_roms
|
|
||||||
ldx #<DSCPNT+1
|
|
||||||
jsr poke_under_roms
|
|
||||||
iny
|
|
||||||
cpy __FAC1+0
|
|
||||||
bne !-
|
|
||||||
|
|
||||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
|
||||||
|
|
||||||
jsr helper_let_strvarcpy
|
|
||||||
|
|
||||||
#else // CONFIG_MEMORY_MODEL_38K
|
|
||||||
|
|
||||||
// Retrieve pointer to destination
|
|
||||||
|
|
||||||
ldy #$02
|
|
||||||
lda (VARPNT), y
|
|
||||||
sta DSCPNT+2
|
|
||||||
dey
|
|
||||||
lda (VARPNT), y
|
|
||||||
sta DSCPNT+1
|
|
||||||
dey
|
|
||||||
|
|
||||||
// .Y is now 0 - copy the content
|
|
||||||
!:
|
|
||||||
lda (__FAC1+1),y
|
|
||||||
sta (DSCPNT+1),y
|
|
||||||
iny
|
|
||||||
cpy __FAC1+0
|
|
||||||
bne !-
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rts
|
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
//
|
||||||
|
// Helper routine to copy string descriptor, for LET command
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_MEMORY_MODEL_38K
|
||||||
|
|
||||||
|
helper_let_strdesccpy:
|
||||||
|
|
||||||
|
ldy #$02
|
||||||
|
lda (VARPNT), y
|
||||||
|
sta DSCPNT+2
|
||||||
|
dey
|
||||||
|
lda (VARPNT), y
|
||||||
|
sta DSCPNT+1
|
||||||
|
dey
|
||||||
|
|
||||||
|
// .Y is now 0 - copy the content
|
||||||
|
!:
|
||||||
|
lda (__FAC1+1),y
|
||||||
|
sta (DSCPNT+1),y
|
||||||
|
iny
|
||||||
|
cpy __FAC1+0
|
||||||
|
bne !-
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
//
|
||||||
|
// Helper routine to copy string descriptor, for LET command
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
|
|
||||||
|
helper_let_strdesccpy:
|
||||||
|
|
||||||
|
ldx #<VARPNT
|
||||||
|
|
||||||
|
ldy #$02
|
||||||
|
jsr peek_under_roms
|
||||||
|
sta DSCPNT+2
|
||||||
|
dey
|
||||||
|
jsr peek_under_roms
|
||||||
|
sta DSCPNT+1
|
||||||
|
dey
|
||||||
|
|
||||||
|
// .Y is now 0 - copy the content
|
||||||
|
!:
|
||||||
|
|
||||||
|
ldx #<__FAC1+1
|
||||||
|
jsr peek_under_roms
|
||||||
|
ldx #<DSCPNT+1
|
||||||
|
jsr poke_under_roms
|
||||||
|
iny
|
||||||
|
cpy __FAC1+0
|
||||||
|
bne !-
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -20,6 +20,7 @@ varstr_free:
|
|||||||
rts
|
rts
|
||||||
!:
|
!:
|
||||||
// Check if string is above FRETOP (in string area)
|
// Check if string is above FRETOP (in string area)
|
||||||
|
// XXX consider moving this check out of this routine
|
||||||
|
|
||||||
jsr varstr_cmp_fretop
|
jsr varstr_cmp_fretop
|
||||||
bcs !+
|
bcs !+
|
||||||
|
|||||||
Reference in new issue
Block a user