string variables can be assigned both in direct and program mode
This commit is contained in:
1 parent
4a94af2fc7
commit
626dbc1eac
6 files changed
+192
-41
No files matched your search
@@ -175,7 +175,7 @@ cmd_let_assign_string:
|
|||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
ldx #<VARPNT
|
ldx #<VARPNT
|
||||||
jsr poke_under_rom
|
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
|
||||||
sta (VARPNT), y
|
sta (VARPNT), y
|
||||||
#endif
|
#endif
|
||||||
@@ -226,13 +226,13 @@ cmd_let_assign_string_not_same:
|
|||||||
|
|
||||||
ldy #$00
|
ldy #$00
|
||||||
lda __FAC1+0
|
lda __FAC1+0
|
||||||
jsr poke_under_rom
|
jsr poke_under_roms
|
||||||
iny
|
iny
|
||||||
lda __FAC1+1
|
lda __FAC1+1
|
||||||
jsr poke_under_rom
|
jsr poke_under_roms
|
||||||
iny
|
iny
|
||||||
lda __FAC1+2
|
lda __FAC1+2
|
||||||
jsr poke_under_rom
|
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
|
||||||
|
|
||||||
@@ -260,17 +260,27 @@ cmd_let_assign_string_not_text_area:
|
|||||||
|
|
||||||
// XXX
|
// XXX
|
||||||
|
|
||||||
// Free the memory of the old string, it is not possible to reuse it
|
|
||||||
|
|
||||||
// XXX
|
|
||||||
|
|
||||||
// Check if the new string is a temporary one - if so, reuse already done alocation
|
// Check if the new string is a temporary one - if so, reuse already done alocation
|
||||||
|
|
||||||
// XXX
|
// XXX
|
||||||
|
|
||||||
// No special case optimization is possible - alocate new memory area and copy the string
|
// No special case optimization is possible - alocate new memory area
|
||||||
|
|
||||||
// XXX
|
ldy #$00
|
||||||
|
|
||||||
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
|
ldx #<VARPNT
|
||||||
|
jsr poke_under_roms
|
||||||
|
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||||
|
sta (VARPNT), y
|
||||||
|
#endif
|
||||||
|
|
||||||
|
lda __FAC1+0
|
||||||
|
sta (VARPNT), y
|
||||||
|
|
||||||
|
jsr varstr_alloc
|
||||||
|
|
||||||
|
// Copy the string
|
||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
|
|
||||||
@@ -279,18 +289,33 @@ cmd_let_assign_string_not_text_area:
|
|||||||
// 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
|
|
||||||
|
jsr helper_let_strvarcpy
|
||||||
// XXX
|
|
||||||
// XXX: implement this
|
|
||||||
// XXX
|
|
||||||
|
|
||||||
#else // CONFIG_MEMORY_MODEL_38K
|
#else // CONFIG_MEMORY_MODEL_38K
|
||||||
|
|
||||||
// XXX
|
// Retrieve pointer to destination
|
||||||
// XXX: implement this
|
|
||||||
// XXX
|
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
|
#endif
|
||||||
|
|
||||||
jmp do_NOT_IMPLEMENTED_error
|
// Free the memory of the old string
|
||||||
|
|
||||||
|
// XXX
|
||||||
|
|
||||||
|
rts
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE-HIGH
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE-HIGH
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
// This has to go $E000 or above - routines below banks out the main BASIC ROM!
|
||||||
|
|
||||||
|
//
|
||||||
|
// Helper routine to copy string variable content, for LET command
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||||
|
|
||||||
|
helper_let_strvarcpy:
|
||||||
|
|
||||||
|
// Unmap BASIC lower ROM
|
||||||
|
|
||||||
|
lda #$26
|
||||||
|
sta CPU_R6510
|
||||||
|
|
||||||
|
// 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 !-
|
||||||
|
|
||||||
|
// Restore default memory mapping
|
||||||
|
|
||||||
|
lda #$27
|
||||||
|
sta CPU_R6510
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -78,8 +78,49 @@ FRMEVL_loop:
|
|||||||
dew TXTPTR
|
dew TXTPTR
|
||||||
#endif
|
#endif
|
||||||
jsr fetch_variable
|
jsr fetch_variable
|
||||||
bcc FRMEVL_got_value
|
bcs !+
|
||||||
|
|
||||||
|
// Found the variable - copy descriptor to FAC1
|
||||||
|
|
||||||
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
|
|
||||||
|
ldx #<VARPNT
|
||||||
|
|
||||||
|
ldy #$00
|
||||||
|
jsr peek_under_roms
|
||||||
|
sta __FAC1+0
|
||||||
|
iny
|
||||||
|
jsr peek_under_roms
|
||||||
|
sta __FAC1+1
|
||||||
|
iny
|
||||||
|
jsr peek_under_roms
|
||||||
|
sta __FAC1+2
|
||||||
|
|
||||||
|
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||||
|
|
||||||
|
jsr helper_frmevl_strdesccpy
|
||||||
|
|
||||||
|
#else // CONFIG_MEMORY_MODEL_38K
|
||||||
|
|
||||||
|
ldy #$00
|
||||||
|
lda (VARPNT),y
|
||||||
|
sta __FAC1+0
|
||||||
|
iny
|
||||||
|
lda (VARPNT),y
|
||||||
|
sta __FAC1+1
|
||||||
|
iny
|
||||||
|
lda (VARPNT),y
|
||||||
|
sta __FAC1+2
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAS_OPCODES_65C02
|
||||||
|
bra FRMEVL_got_value
|
||||||
|
#else
|
||||||
|
jmp FRMEVL_got_value
|
||||||
|
#endif
|
||||||
|
|
||||||
|
!:
|
||||||
// There is one possibility left - a floating point value
|
// There is one possibility left - a floating point value
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE-HIGH
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE-HIGH
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
// This has to go $E000 or above - routines below banks out the main BASIC ROM!
|
||||||
|
|
||||||
|
//
|
||||||
|
// Helper routine to copy string descriptor, for expression evaluator
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||||
|
|
||||||
|
helper_frmevl_strdesccpy:
|
||||||
|
|
||||||
|
// Unmap BASIC lower ROM
|
||||||
|
|
||||||
|
lda #$26
|
||||||
|
sta CPU_R6510
|
||||||
|
|
||||||
|
// Copy string descriptor
|
||||||
|
|
||||||
|
ldy #$00
|
||||||
|
lda (VARPNT),y
|
||||||
|
sta __FAC1+0
|
||||||
|
iny
|
||||||
|
lda (VARPNT),y
|
||||||
|
sta __FAC1+1
|
||||||
|
iny
|
||||||
|
lda (VARPNT),y
|
||||||
|
sta __FAC1+2
|
||||||
|
|
||||||
|
// Restore default memory mapping
|
||||||
|
|
||||||
|
lda #$27
|
||||||
|
sta CPU_R6510
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -15,7 +15,9 @@
|
|||||||
// - https://sites.google.com/site/h2obsession/CBM/basic/variable-format
|
// - https://sites.google.com/site/h2obsession/CBM/basic/variable-format
|
||||||
//
|
//
|
||||||
// Input:
|
// Input:
|
||||||
// - DSCPNT+1, DSCPNT+2 - pointer to string descriptor, first pointed byte should contain desired length
|
// - VARPNT - pointer to string descriptor, first pointed byte should contain desired length
|
||||||
|
// Output:
|
||||||
|
// - fills-in pointer in the string descriptor
|
||||||
//
|
//
|
||||||
|
|
||||||
// XXX test this routine
|
// XXX test this routine
|
||||||
@@ -39,7 +41,7 @@ varstr_alloc_retry:
|
|||||||
lda FRETOP+1
|
lda FRETOP+1
|
||||||
sta INDEX+1
|
sta INDEX+1
|
||||||
|
|
||||||
// Lower FRETOP to make space for string descriptor
|
// Lower FRETOP to make space for the back-pointer
|
||||||
|
|
||||||
#if !HAS_OPCODES_65CE02
|
#if !HAS_OPCODES_65CE02
|
||||||
|
|
||||||
@@ -60,7 +62,7 @@ varstr_alloc_retry:
|
|||||||
// Create the back-pointer to the string descriptor
|
// Create the back-pointer to the string descriptor
|
||||||
|
|
||||||
ldy #$00
|
ldy #$00
|
||||||
lda DSCPNT+1
|
lda VARPNT+0
|
||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
ldx #<FRETOP
|
ldx #<FRETOP
|
||||||
@@ -70,7 +72,7 @@ varstr_alloc_retry:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
iny
|
iny
|
||||||
lda DSCPNT+2
|
lda VARPNT+1
|
||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
jsr poke_under_roms
|
jsr poke_under_roms
|
||||||
@@ -80,15 +82,15 @@ varstr_alloc_retry:
|
|||||||
|
|
||||||
// Now lower FRETOP again to make space for the string content
|
// Now lower FRETOP again to make space for the string content
|
||||||
|
|
||||||
dey // $01 -> $00
|
ldy #$00
|
||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
ldx #<DSCPNT+1
|
ldx #<VARPNT
|
||||||
jsr peek_under_roms
|
jsr peek_under_roms
|
||||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||||
jsr peek_under_roms_via_DSCPNT_PLUS_1
|
jsr peek_under_roms_via_VARPNT
|
||||||
#else // CONFIG_MEMORY_MODEL_38K
|
#else // CONFIG_MEMORY_MODEL_38K
|
||||||
lda (DSCPNT+1),y
|
lda (VARPNT),y
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
jsr varstr_FRETOP_down_A
|
jsr varstr_FRETOP_down_A
|
||||||
@@ -96,24 +98,21 @@ varstr_alloc_retry:
|
|||||||
|
|
||||||
// Success - fill in the string descriptor
|
// Success - fill in the string descriptor
|
||||||
|
|
||||||
iny // $00 -> $01
|
ldy #$01
|
||||||
lda FRETOP+0
|
|
||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
ldx #<FRETOP
|
ldx #<VARPNT
|
||||||
|
lda FRETOP+0
|
||||||
jsr poke_under_roms
|
jsr poke_under_roms
|
||||||
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
|
||||||
sta (FRETOP), y
|
|
||||||
#endif
|
|
||||||
|
|
||||||
iny
|
iny
|
||||||
lda FRETOP+1
|
lda FRETOP+1
|
||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
|
||||||
ldx #<DSCPNT+1
|
|
||||||
jsr poke_under_roms
|
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
|
||||||
sta (DSCPNT+1), y
|
lda FRETOP+0
|
||||||
|
sta (VARPNT), y
|
||||||
|
iny
|
||||||
|
lda FRETOP+1
|
||||||
|
sta (VARPNT), y
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// The end
|
// The end
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
// XXX test this routine
|
// XXX test this routine
|
||||||
// XXX check if this entry point is needed
|
// XXX check if this entry point is needed
|
||||||
|
|
||||||
varstr_free:
|
varstr_free: // XXX is it needed? if not, we do not need peek_under_roms_via_DSCPNT_PLUS_1
|
||||||
|
|
||||||
// First copy the string descriptor data to DSCPNT
|
// First copy the string descriptor data to DSCPNT
|
||||||
// XXX write optimized version for CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
// XXX write optimized version for CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||||
@@ -58,7 +58,7 @@ varstr_free:
|
|||||||
|
|
||||||
varstr_free_DSCPNT_set:
|
varstr_free_DSCPNT_set:
|
||||||
|
|
||||||
// consider moving size check (DSCPNT+0) here
|
// XXX consider moving size check (DSCPNT+0) here
|
||||||
|
|
||||||
// XXX
|
// XXX
|
||||||
// XXX check if string is located above FRETOP, handle case if it is not
|
// XXX check if string is located above FRETOP, handle case if it is not
|
||||||
|
|||||||
Reference in new issue
Block a user