more cleanup in BASIC

This commit is contained in:
FeralChild64 committed 2020-06-28 20:52:49 +02:00
1 parent 0a85c12f42
commit 2085e426c8
8 files changed
+149 -157

No files matched your search

+6
View File
@@ -71,6 +71,12 @@
.label FAC2_mantissa = $6A // $6A - $6D .label FAC2_mantissa = $6A // $6A - $6D
.label FAC2_sign = $6E .label FAC2_sign = $6E
// We re-use FAC2 for memory move pointers, since we cannot be doing calculations while moving memory
.label memmove__src = $69
.label memmove__dst = $6B
.label memmove__size = $6D
.label ARISGN = $6F // -- NOT IMPLEMENTED -- .label ARISGN = $6F // -- NOT IMPLEMENTED --
.label FACOV = $70 // FAC1 low order mantissa .label FACOV = $70 // FAC1 low order mantissa
.label FBUFPT = $71 // $71-$72 -- NOT IMPLEMENTED -- .label FBUFPT = $71 // $71-$72 -- NOT IMPLEMENTED --
-6
View File
@@ -11,9 +11,3 @@
.label __tokenise_work3 = $0B // COUNT .label __tokenise_work3 = $0B // COUNT
.label __tokenise_work4 = $0F // GARBFL .label __tokenise_work4 = $0F // GARBFL
.label __tokenise_work5 = $0C // DIMFLG .label __tokenise_work5 = $0C // DIMFLG
// We re-use FAC2 for memory move pointers, since
// we can't be doing calculations while moving memory
.label __memmove_src = $69
.label __memmove_dst = $6B
.label __memmove_size = $6D
+38 -38
View File
@@ -9,28 +9,28 @@ basic_shift_mem_down_and_relink:
// Destination is OLDTXT // Destination is OLDTXT
lda OLDTXT+0 lda OLDTXT+0
sta __memmove_dst+0 sta memmove__dst+0
lda OLDTXT+1 lda OLDTXT+1
sta __memmove_dst+1 sta memmove__dst+1
// Source is that plus X // Source is that plus X
txa txa
pha // also keep for later pha // also keep for later
clc clc
adc OLDTXT+0 adc OLDTXT+0
sta __memmove_src+0 sta memmove__src+0
lda OLDTXT+1 lda OLDTXT+1
adc #0 adc #0
sta __memmove_src+1 sta memmove__src+1
// Size is distance from source to end of BASIC text. // Size is distance from source to end of BASIC text.
lda VARTAB+0 lda VARTAB+0
sec sec
sbc __memmove_src+0 sbc memmove__src+0
sta __memmove_size+0 sta memmove__size+0
lda VARTAB+1 lda VARTAB+1
sbc __memmove_src+1 sbc memmove__src+1
sta __memmove_size+1 sta memmove__size+1
// jsr printf // jsr printf
// .text "TOP OF BASIC = $" // .text "TOP OF BASIC = $"
@@ -38,14 +38,14 @@ basic_shift_mem_down_and_relink:
// .byte $f0,<VARTAB,>VARTAB // .byte $f0,<VARTAB,>VARTAB
// .byte $0d // .byte $0d
// .text "SHIFTING DOWN $" // .text "SHIFTING DOWN $"
// .byte $f1,<__memmove_size,>__memmove_size // .byte $f1,<memmove__size,>memmove__size
// .byte $f0,<__memmove_size,>__memmove_size // .byte $f0,<memmove__size,>memmove__size
// .text " BYTES FROM $" // .text " BYTES FROM $"
// .byte $f1,<__memmove_src,>__memmove_src // .byte $f1,<memmove__src,>memmove__src
// .byte $f0,<__memmove_src,>__memmove_src // .byte $f0,<memmove__src,>memmove__src
// .text " TO $" // .text " TO $"
// .byte $f1,<__memmove_dst,>__memmove_dst // .byte $f1,<memmove__dst,>memmove__dst
// .byte $f0,<__memmove_dst,>__memmove_dst // .byte $f0,<memmove__dst,>memmove__dst
// .byte $0d,0 // .byte $0d,0
// The copy routine that copies under the ROMs is as simple // The copy routine that copies under the ROMs is as simple
@@ -59,44 +59,44 @@ basic_shift_mem_down_and_relink:
// This means we have to then reduce the source and // This means we have to then reduce the source and
// target pointers by the same amount // target pointers by the same amount
lda __memmove_size+0 lda memmove__size+0
eor #$ff eor #$ff
sta __tokenise_work3 sta __tokenise_work3
sta __memmove_size+0 sta memmove__size+0
lda __memmove_src+0 lda memmove__src+0
sec sec
sbc __tokenise_work3 sbc __tokenise_work3
sta __memmove_src+0 sta memmove__src+0
lda __memmove_src+1 lda memmove__src+1
sbc #0 sbc #0
sta __memmove_src+1 sta memmove__src+1
lda __memmove_dst+0 lda memmove__dst+0
sec sec
sbc __tokenise_work3 sbc __tokenise_work3
sta __memmove_dst+0 sta memmove__dst+0
lda __memmove_dst+1 lda memmove__dst+1
sbc #0 sbc #0
sta __memmove_dst+1 sta memmove__dst+1
// Increase copy page count so we can post-decrement compare with $00 // Increase copy page count so we can post-decrement compare with $00
inc __memmove_size+1 inc memmove__size+1
// jsr printf // jsr printf
// .text "REVISED BOUNDS $" // .text "REVISED BOUNDS $"
// .byte $f1,<__memmove_size,>__memmove_size // .byte $f1,<memmove__size,>memmove__size
// .byte $f0,<__memmove_size,>__memmove_size // .byte $f0,<memmove__size,>memmove__size
// .text " BYTES FROM $" // .text " BYTES FROM $"
// .byte $f1,<__memmove_src,>__memmove_src // .byte $f1,<memmove__src,>memmove__src
// .byte $f0,<__memmove_src,>__memmove_src // .byte $f0,<memmove__src,>memmove__src
// .text " TO $" // .text " TO $"
// .byte $f1,<__memmove_dst,>__memmove_dst // .byte $f1,<memmove__dst,>memmove__dst
// .byte $f0,<__memmove_dst,>__memmove_dst // .byte $f0,<memmove__dst,>memmove__dst
// .byte $0d,0 // .byte $0d,0
// Get Y value ready for the copy // Get Y value ready for the copy
ldy __memmove_size+0 ldy memmove__size+0
jsr shift_mem_down jsr shift_mem_down
@@ -131,7 +131,7 @@ relink_down_next_line:
sec sec
sbc __tokenise_work3 sbc __tokenise_work3
sta __memmove_src+0 sta memmove__src+0
iny iny
#if CONFIG_MEMORY_MODEL_60K #if CONFIG_MEMORY_MODEL_60K
@@ -143,10 +143,10 @@ relink_down_next_line:
#endif #endif
sbc #0 sbc #0
sta __memmove_src+1 sta memmove__src+1
ldy #0 ldy #0
lda __memmove_src+0 lda memmove__src+0
#if CONFIG_MEMORY_MODEL_60K #if CONFIG_MEMORY_MODEL_60K
ldx #<OLDTXT+0 ldx #<OLDTXT+0
@@ -156,7 +156,7 @@ relink_down_next_line:
#endif #endif
iny iny
lda __memmove_src+1 lda memmove__src+1
#if CONFIG_MEMORY_MODEL_60K #if CONFIG_MEMORY_MODEL_60K
jsr poke_under_roms jsr poke_under_roms
@@ -166,9 +166,9 @@ relink_down_next_line:
relink_down_loop: relink_down_loop:
// Now advance pointer to the next line, // Now advance pointer to the next line,
lda __memmove_src+0 lda memmove__src+0
sta OLDTXT+0 sta OLDTXT+0
lda __memmove_src+1 lda memmove__src+1
sta OLDTXT+1 sta OLDTXT+1
// Have we run out of lines to patch? // Have we run out of lines to patch?
+47 -47
View File
@@ -13,35 +13,35 @@ basic_shift_mem_up_and_relink:
txa txa
clc clc
adc VARTAB+0 adc VARTAB+0
sta __memmove_dst+0 sta memmove__dst+0
lda VARTAB+1 lda VARTAB+1
adc #0 adc #0
sta __memmove_dst+1 sta memmove__dst+1
lda __memmove_dst+0 lda memmove__dst+0
sec sec
sbc #1 sbc #1
sta __memmove_dst+0 sta memmove__dst+0
lda __memmove_dst+1 lda memmove__dst+1
sbc #0 sbc #0
sta __memmove_dst+1 sta memmove__dst+1
// End point of source is just current end of BASIC text // End point of source is just current end of BASIC text
lda VARTAB+0 lda VARTAB+0
sec sec
sbc #1 sbc #1
sta __memmove_src+0 sta memmove__src+0
lda VARTAB+1 lda VARTAB+1
sbc #0 sbc #0
sta __memmove_src+1 sta memmove__src+1
// Work out size of region to copy // Work out size of region to copy
lda VARTAB+0 lda VARTAB+0
sec sec
sbc OLDTXT+0 sbc OLDTXT+0
sta __memmove_size+0 sta memmove__size+0
lda VARTAB+1 lda VARTAB+1
sbc OLDTXT+1 sbc OLDTXT+1
sta __memmove_size+1 sta memmove__size+1
// jsr printf // jsr printf
// .text "TOP OF BASIC = $" // .text "TOP OF BASIC = $"
@@ -49,54 +49,54 @@ basic_shift_mem_up_and_relink:
// .byte $f0,<VARTAB,>VARTAB // .byte $f0,<VARTAB,>VARTAB
// .byte $0d // .byte $0d
// .text "SHIFTING UP $" // .text "SHIFTING UP $"
// .byte $f1,<__memmove_size,>__memmove_size // .byte $f1,<memmove__size,>memmove__size
// .byte $f0,<__memmove_size,>__memmove_size // .byte $f0,<memmove__size,>memmove__size
// .text " BYTES FROM $" // .text " BYTES FROM $"
// .byte $f1,<__memmove_src,>__memmove_src // .byte $f1,<memmove__src,>memmove__src
// .byte $f0,<__memmove_src,>__memmove_src // .byte $f0,<memmove__src,>memmove__src
// .text " TO $" // .text " TO $"
// .byte $f1,<__memmove_dst,>__memmove_dst // .byte $f1,<memmove__dst,>memmove__dst
// .byte $f0,<__memmove_dst,>__memmove_dst // .byte $f0,<memmove__dst,>memmove__dst
// .byte $0d,0 // .byte $0d,0
// To make life simple for the copy routine that lives in RAM, // To make life simple for the copy routine that lives in RAM,
// we have to adjust the end pointers down one page and set Y to the low // we have to adjust the end pointers down one page and set Y to the low
// byte of the copy size. // byte of the copy size.
lda __memmove_src+0 lda memmove__src+0
sec sec
sbc __memmove_size+0 sbc memmove__size+0
sta __memmove_src+0 sta memmove__src+0
lda __memmove_src+1 lda memmove__src+1
sbc #0 sbc #0
sta __memmove_src+1 sta memmove__src+1
lda __memmove_dst+0 lda memmove__dst+0
sec sec
sbc __memmove_size+0 sbc memmove__size+0
sta __memmove_dst+0 sta memmove__dst+0
lda __memmove_dst+1 lda memmove__dst+1
sbc #0 sbc #0
sta __memmove_dst+1 sta memmove__dst+1
// Now make exit easy, by being able to check for zero on size high byte when done // Now make exit easy, by being able to check for zero on size high byte when done
inc __memmove_size+1 inc memmove__size+1
// Then set Y to the number offset required // Then set Y to the number offset required
ldy __memmove_size+0 ldy memmove__size+0
iny iny
stx __tokenise_work3 stx __tokenise_work3
// jsr printf // jsr printf
// .text "REVISED BOUNDS $" // .text "REVISED BOUNDS $"
// .byte $f1,<__memmove_size,>__memmove_size // .byte $f1,<memmove__size,>memmove__size
// .byte $f0,<__memmove_size,>__memmove_size // .byte $f0,<memmove__size,>memmove__size
// .text " BYTES FROM $" // .text " BYTES FROM $"
// .byte $f1,<__memmove_src,>__memmove_src // .byte $f1,<memmove__src,>memmove__src
// .byte $f0,<__memmove_src,>__memmove_src // .byte $f0,<memmove__src,>memmove__src
// .text " TO $" // .text " TO $"
// .byte $f1,<__memmove_dst,>__memmove_dst // .byte $f1,<memmove__dst,>memmove__dst
// .byte $f0,<__memmove_dst,>__memmove_dst // .byte $f0,<memmove__dst,>memmove__dst
// .byte $0d,0 // .byte $0d,0
// Do the copy // Do the copy
@@ -143,10 +143,10 @@ relink_up_next_line:
lda (OLDTXT),y lda (OLDTXT),y
#endif #endif
sta __memmove_dst+0 sta memmove__dst+0
clc clc
adc __tokenise_work3 adc __tokenise_work3
sta __memmove_src+0 sta memmove__src+0
iny iny
php php
@@ -159,27 +159,27 @@ relink_up_next_line:
lda (OLDTXT),y lda (OLDTXT),y
#endif #endif
sta __memmove_dst+1 sta memmove__dst+1
plp plp
adc #0 adc #0
sta __memmove_src+1 sta memmove__src+1
// jsr printf // jsr printf
// .text "LINE ADDR = $" // .text "LINE ADDR = $"
// .byte $f1,<OLDTXT,>VARTAB // .byte $f1,<OLDTXT,>VARTAB
// .byte $f0,<OLDTXT,>VARTAB // .byte $f0,<OLDTXT,>VARTAB
// .text $d," BEFORE = $" // .text $d," BEFORE = $"
// .byte $f1,<__memmove_dst,>__memmove_dst // .byte $f1,<memmove__dst,>memmove__dst
// .byte $f0,<__memmove_dst,>__memmove_dst // .byte $f0,<memmove__dst,>memmove__dst
// .text ", AFTER = $" // .text ", AFTER = $"
// .byte $f1,<__memmove_src,>__memmove_src // .byte $f1,<memmove__src,>memmove__src
// .byte $f0,<__memmove_src,>__memmove_src // .byte $f0,<memmove__src,>memmove__src
// .byte $d // .byte $d
// .byte 0 // .byte 0
// Write __memmove_src back to current line pointer // Write memmove__src back to current line pointer
ldy #0 ldy #0
lda __memmove_src+0 lda memmove__src+0
#if CONFIG_MEMORY_MODEL_60K #if CONFIG_MEMORY_MODEL_60K
ldx #<OLDTXT+0 ldx #<OLDTXT+0
@@ -189,7 +189,7 @@ relink_up_next_line:
#endif #endif
iny iny
lda __memmove_src+1 lda memmove__src+1
#if CONFIG_MEMORY_MODEL_60K #if CONFIG_MEMORY_MODEL_60K
jsr poke_under_roms jsr poke_under_roms
@@ -199,9 +199,9 @@ relink_up_next_line:
relink_up_loop: relink_up_loop:
// Now advance pointer to the next line, // Now advance pointer to the next line,
lda __memmove_src+0 lda memmove__src+0
sta OLDTXT+0 sta OLDTXT+0
lda __memmove_src+1 lda memmove__src+1
sta OLDTXT+1 sta OLDTXT+1
// Have we run out of lines to patch? // Have we run out of lines to patch?
+8 -10
View File
@@ -7,22 +7,20 @@
shift_mem_down: shift_mem_down:
// Move __memmove_size bytes from __memmove_src to __memmove_dst, // Move memmove__size bytes from memmove__src to memmove__dst, where memmove__dst > memmove__src
// where __memmove_dst > __memmove_src //
// This means we have to copy from the back end down. // This means we have to copy from the back end down.
// This routine assumes the pointers are already pointed // This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized
// to the end of the areas, and that Y is correctly initialised
// to allow the copy to begin.
php php
!: !:
lda (__memmove_src),y lda (memmove__src),y
sta (__memmove_dst),y sta (memmove__dst),y
iny iny
bne !- bne !-
inc __memmove_src+1 inc memmove__src+1
inc __memmove_dst+1 inc memmove__dst+1
dec __memmove_size+1 dec memmove__size+1
bne !- bne !-
plp plp
rts rts
+8 -10
View File
@@ -7,22 +7,20 @@
shift_mem_up: shift_mem_up:
// Move __memmove_size bytes from __memmove_src to __memmove_dst, // Move memmove__size bytes from memmove__src to memmove__dst, where memmove__dst > memmove__src
// where __memmove_dst > __memmove_src //
// This means we have to copy from the back end down. // This means we have to copy from the back end down.
// This routine assumes the pointers are already pointed // This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized
// to the end of the areas, and that Y is correctly initialised
// to allow the copy to begin.
php php
!: !:
lda (__memmove_src),y lda (memmove__src),y
sta (__memmove_dst),y sta (memmove__dst),y
dey dey
bne !- bne !-
dec __memmove_src+1 dec memmove__src+1
dec __memmove_dst+1 dec memmove__dst+1
dec __memmove_size+1 dec memmove__size+1
bne !- bne !-
plp plp
rts rts
+16 -20
View File
@@ -72,12 +72,10 @@ peek_under_roms_via_FAC1_PLUS_1:
shift_mem_up: shift_mem_up:
// Move __memmove_size bytes from __memmove_src to __memmove_dst, // Move memmove__size bytes from memmove__src to memmove__dst, where memmove__dst > memmove__src
// where __memmove_dst > __memmove_src //
// This means we have to copy from the back end down. // This means we have to copy from the back end down.
// This routine assumes the pointers are already pointed // This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized
// to the end of the areas, and that Y is correctly initialised
// to allow the copy to begin.
// Unmap BASIC lower ROM // Unmap BASIC lower ROM
@@ -88,13 +86,13 @@ shift_mem_up:
// Perform the copying // Perform the copying
!: !:
lda (__memmove_src),y lda (memmove__src),y
sta (__memmove_dst),y sta (memmove__dst),y
dey dey
bne !- bne !-
dec __memmove_src+1 dec memmove__src+1
dec __memmove_dst+1 dec memmove__dst+1
dec __memmove_size+1 dec memmove__size+1
bne !- bne !-
#if HAS_OPCODES_65C02 #if HAS_OPCODES_65C02
@@ -106,12 +104,10 @@ shift_mem_up:
shift_mem_down: shift_mem_down:
// Move __memmove_size bytes from __memmove_src to __memmove_dst, // Move memmove__size bytes from memmove__src to memmove__dst, where memmove__dst > memmove__src
// where __memmove_dst > __memmove_src //
// This means we have to copy from the back end down. // This means we have to copy from the back end down.
// This routine assumes the pointers are already pointed // This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized
// to the end of the areas, and that Y is correctly initialised
// to allow the copy to begin.
// Unmap BASIC lower ROM // Unmap BASIC lower ROM
@@ -122,13 +118,13 @@ shift_mem_down:
// Perform the copying // Perform the copying
!: !:
lda (__memmove_src),y lda (memmove__src),y
sta (__memmove_dst),y sta (memmove__dst),y
iny iny
bne !- bne !-
inc __memmove_src+1 inc memmove__src+1
inc __memmove_dst+1 inc memmove__dst+1
dec __memmove_size+1 dec memmove__size+1
bne !- bne !-
// FALLTROUGH // FALLTROUGH
+26 -26
View File
@@ -70,44 +70,44 @@ memmap_allram_routine:
rts rts
shift_mem_up_routine: shift_mem_up_routine:
// Move __memmove_size bytes from __memmove_src to __memmove_dst,
// where __memmove_dst > __memmove_src // Move memmove__size bytes from memmove__src to memmove__dst, where memmove__dst > memmove__src
//
// This means we have to copy from the back end down. // This means we have to copy from the back end down.
// This routine assumes the pointers are already pointed // This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized
// to the end of the areas, and that Y is correctly initialised
// to allow the copy to begin.
php php
jsr memmap_allram jsr memmap_allram
smu1: !:
lda (__memmove_src),y lda (memmove__src),y
sta (__memmove_dst),y sta (memmove__dst),y
dey dey
bne smu1 bne !-
dec __memmove_src+1 dec memmove__src+1
dec __memmove_dst+1 dec memmove__dst+1
dec __memmove_size+1 dec memmove__size+1
bne smu1 bne !-
plp plp
jmp memmap_normal jmp memmap_normal
shift_mem_down_routine: shift_mem_down_routine:
// Move __memmove_size bytes from __memmove_src to __memmove_dst,
// where __memmove_dst > __memmove_src // Move memmove__size bytes from memmove__src to memmove__dst, where memmove__dst > memmove__src
//
// This means we have to copy from the back end down. // This means we have to copy from the back end down.
// This routine assumes the pointers are already pointed // This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized
// to the end of the areas, and that Y is correctly initialised
// to allow the copy to begin.
php php
jsr memmap_allram jsr memmap_allram
smd1: !:
lda (__memmove_src),y lda (memmove__src),y
sta (__memmove_dst),y sta (memmove__dst),y
iny iny
bne smd1 bne !-
inc __memmove_src+1 inc memmove__src+1
inc __memmove_dst+1 inc memmove__dst+1
dec __memmove_size+1 dec memmove__size+1
bne smd1 bne !-
plp plp
jmp memmap_normal jmp memmap_normal