added routine to free string memory
This commit is contained in:
1 parent
2c86c577bc
commit
aa101f79c6
4 files changed
+80
-9
No files matched your search
@@ -45,7 +45,7 @@ varstr_alloc_retry:
|
|||||||
#if !HAS_OPCODES_65CE02
|
#if !HAS_OPCODES_65CE02
|
||||||
|
|
||||||
lda #$02
|
lda #$02
|
||||||
jsr varstr_FRETOP_down
|
jsr varstr_FRETOP_down_A
|
||||||
|
|
||||||
#else // HAS_OPCODES_65CE02 - this time code is slightly longer, but faster
|
#else // HAS_OPCODES_65CE02 - this time code is slightly longer, but faster
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ varstr_alloc_retry:
|
|||||||
lda (DSCPNT),y
|
lda (DSCPNT),y
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
jsr varstr_FRETOP_down
|
jsr varstr_FRETOP_down_A
|
||||||
bcs varstr_alloc_fail
|
bcs varstr_alloc_fail
|
||||||
|
|
||||||
// Success - fill in the string descriptor
|
// Success - fill in the string descriptor
|
||||||
|
|||||||
@@ -6,13 +6,13 @@
|
|||||||
// Helper routines for 'varstr_alloc'
|
// Helper routines for 'varstr_alloc'
|
||||||
//
|
//
|
||||||
|
|
||||||
varstr_FRETOP_down: // .A - bytes to lower FRETOP, uses memmove__tmp
|
varstr_FRETOP_down_A: // .A - bytes to lower FRETOP, uses DSCPNT+2
|
||||||
|
|
||||||
sta memmove__tmp
|
sta DSCPNT+2
|
||||||
|
|
||||||
sec
|
sec
|
||||||
lda FRETOP+0
|
lda FRETOP+0
|
||||||
sbc memmove__tmp
|
sbc DSCPNT+2
|
||||||
sta FRETOP+0
|
sta FRETOP+0
|
||||||
bcs !+
|
bcs !+
|
||||||
dec FRETOP+1
|
dec FRETOP+1
|
||||||
|
|||||||
@@ -61,15 +61,68 @@ varstr_free:
|
|||||||
cmp FRETOP+1
|
cmp FRETOP+1
|
||||||
bne varstr_free_inside
|
bne varstr_free_inside
|
||||||
|
|
||||||
// This is the lowest string - increase FRETOP, this way
|
// This is the lowest string - so just increase FRETOP, this way
|
||||||
// the garbage collector will not be needed that quickly
|
// the garbage collector will not be needed that quickly
|
||||||
|
|
||||||
// XXX implement this
|
jsr varstr_FRETOP_up // free the string data
|
||||||
|
|
||||||
|
#if !HAS_OPCODES_65CE02
|
||||||
|
|
||||||
|
lda #$02 // free the back-pointer
|
||||||
|
sta DSCPNT+2
|
||||||
|
jmp varstr_FRETOP_up
|
||||||
|
|
||||||
|
#else // HAS_OPCODES_65CE02
|
||||||
|
|
||||||
|
inw FRETOP // free the back-pointer
|
||||||
|
inw FRETOP
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
varstr_free_inside:
|
varstr_free_inside:
|
||||||
|
|
||||||
// THis is not the lowest string; mark it as free
|
// This is not the lowest string; mark it as free
|
||||||
|
// First preserve the string size, it will make it easier for the garbage collector
|
||||||
|
|
||||||
// XXX implement this
|
lda DSCPNT+2
|
||||||
|
tay
|
||||||
|
dey
|
||||||
|
|
||||||
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
|
ldx #<FRETOP
|
||||||
|
jsr poke_under_roms
|
||||||
|
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||||
|
sta (FRETOP), y
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Now increase DSCPNT+0/+1 to point to the back-pointer
|
||||||
|
|
||||||
|
clc
|
||||||
|
lda DSCPNT+0
|
||||||
|
adc DSCPNT+2
|
||||||
|
sta DSCPNT+0
|
||||||
|
bcc !+
|
||||||
|
inc DSCPNT+1
|
||||||
|
!:
|
||||||
|
// Fill the back-pointer with 0
|
||||||
|
|
||||||
|
lda #$00
|
||||||
|
ldy #$00
|
||||||
|
|
||||||
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
|
ldx #<DSCPNT
|
||||||
|
jsr poke_under_roms
|
||||||
|
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||||
|
sta (DSCPNT), y
|
||||||
|
#endif
|
||||||
|
|
||||||
|
iny // $00 -> $01
|
||||||
|
|
||||||
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
|
jmp poke_under_roms
|
||||||
|
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||||
|
sta (DSCPNT), y
|
||||||
rts
|
rts
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
//
|
||||||
|
// Helper routines for 'varstr_free'
|
||||||
|
//
|
||||||
|
|
||||||
|
varstr_FRETOP_up: // DSCPNT+2 - bytes to increment FRETO, uses DSCPNT+2
|
||||||
|
|
||||||
|
clc
|
||||||
|
lda FRETOP+0
|
||||||
|
adc DSCPNT+2
|
||||||
|
sta FRETOP+0
|
||||||
|
bcc !+
|
||||||
|
inc FRETOP+1
|
||||||
|
!:
|
||||||
|
rts
|
||||||
Reference in new issue
Block a user