GOTO command got performance optimization
This commit is contained in:
1 parent
a17f810d50
commit
76ed0d1f9f
4 files changed
+73
-28
No files matched your search
@@ -6,32 +6,83 @@
|
|||||||
cmd_run:
|
cmd_run:
|
||||||
|
|
||||||
// RUN clears all variables
|
// RUN clears all variables
|
||||||
|
|
||||||
jsr do_clr
|
jsr do_clr
|
||||||
|
|
||||||
cmd_goto:
|
// Initialize OLDTXT pointer, disable Kernal messages
|
||||||
|
|
||||||
// XXX optimize this: deduplicate last part (and init_oldtxt) with load/verify,
|
jsr init_oldtxt
|
||||||
// if line number greater than current line - find line backwards
|
|
||||||
|
|
||||||
// Disable Kernal messages
|
|
||||||
lda #$00
|
lda #$00
|
||||||
jsr JSETMSG
|
jsr JSETMSG
|
||||||
|
|
||||||
// Reset line pointer to first line of program.
|
// Check if we have any paramenters
|
||||||
jsr init_oldtxt
|
|
||||||
|
|
||||||
jsr is_end_of_statement
|
jsr is_end_of_statement
|
||||||
bcs !+
|
bcs cmd_run_goto_launch
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
cmd_goto:
|
||||||
|
|
||||||
|
// GOTO requires line number
|
||||||
|
|
||||||
jsr fetch_line_number
|
jsr fetch_line_number
|
||||||
bcs_16 do_SYNTAX_error
|
bcs_16 do_SYNTAX_error
|
||||||
jsr find_line
|
|
||||||
bcc !+
|
// Check for direct mode
|
||||||
// Line does not exist, so report error
|
|
||||||
jmp do_UNDEFD_STATEMENT_error
|
lda CURLIN+1
|
||||||
|
bmi cmd_goto_direct
|
||||||
|
|
||||||
|
// Not a direct mode - compare desired line number (LINNUM) with the current one (CURLIN)
|
||||||
|
|
||||||
|
lda LINNUM+1
|
||||||
|
cmp CURLIN+1
|
||||||
|
bne !+
|
||||||
|
lda LINNUM+0
|
||||||
|
cmp CURLIN+0
|
||||||
!:
|
!:
|
||||||
|
// If desired line number is lower - search line number from start
|
||||||
|
|
||||||
|
bcc cmd_goto_from_start
|
||||||
|
|
||||||
|
// Else - search from the current line
|
||||||
|
|
||||||
|
jsr find_line_from_current
|
||||||
|
|
||||||
|
#if HAS_OPCODES_65C02
|
||||||
|
bra cmd_goto_check
|
||||||
|
#else
|
||||||
|
jmp cmd_goto_check
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cmd_goto_direct:
|
||||||
|
|
||||||
|
// Disable Kernal messages
|
||||||
|
|
||||||
|
lda #$00
|
||||||
|
jsr JSETMSG
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
cmd_goto_from_start:
|
||||||
|
|
||||||
|
// Direct mode - find the line from the beginning
|
||||||
|
|
||||||
|
jsr find_line_from_start
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
cmd_goto_check:
|
||||||
|
|
||||||
|
bcs_16 do_UNDEFD_STATEMENT_error
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
cmd_run_goto_launch:
|
||||||
|
|
||||||
// Run it!
|
// Run it!
|
||||||
|
|
||||||
pha
|
pha
|
||||||
pha
|
pha
|
||||||
jmp execute_line
|
jmp execute_line
|
||||||
@@ -3,23 +3,17 @@
|
|||||||
// #LAYOUT# * * #IGNORE
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
|
||||||
// Find the BASIC line with number LINNUM
|
// Find the BASIC line with number in LINNUM
|
||||||
|
|
||||||
// XXX it should be possible to start from the current line (OLDTXT), or from the startup,
|
|
||||||
// depending on the current and target line number
|
|
||||||
|
|
||||||
|
|
||||||
find_line:
|
find_line_from_start:
|
||||||
|
|
||||||
// Get pointer to start of BASIC text
|
// Get pointer to start of BASIC text
|
||||||
lda TXTTAB+0
|
jsr init_oldtxt
|
||||||
sta OLDTXT+0
|
|
||||||
lda TXTTAB+1
|
|
||||||
sta OLDTXT+1
|
|
||||||
|
|
||||||
// FALLTROUGH
|
// FALLTROUGH
|
||||||
|
|
||||||
find_line_loop:
|
find_line_from_current:
|
||||||
|
|
||||||
// Check if line is not empty
|
// Check if line is not empty
|
||||||
|
|
||||||
@@ -100,9 +94,9 @@ find_line_next:
|
|||||||
sta OLDTXT+0
|
sta OLDTXT+0
|
||||||
|
|
||||||
#if HAS_OPCODES_65C02
|
#if HAS_OPCODES_65C02
|
||||||
bra find_line_loop
|
bra find_line_from_current
|
||||||
#else
|
#else
|
||||||
jmp find_line_loop
|
jmp find_line_from_current
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
find_line_fail:
|
find_line_fail:
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
insert_line:
|
insert_line:
|
||||||
|
|
||||||
// ASSUMES find_line has been called to set the insert point.
|
// ASSUMES find_line_from_start has been called to set the insert point.
|
||||||
|
|
||||||
// jsr printf
|
// jsr printf
|
||||||
// .text "INSERTING LINE AT $"
|
// .text "INSERTING LINE AT $"
|
||||||
|
|||||||
@@ -169,12 +169,12 @@ shell_add_delete_line:
|
|||||||
jsr update_VARTAB_do_clr
|
jsr update_VARTAB_do_clr
|
||||||
|
|
||||||
// Check if line already present
|
// Check if line already present
|
||||||
jsr find_line
|
jsr find_line_from_start
|
||||||
bcs !+
|
bcs !+
|
||||||
|
|
||||||
// Line already present - delete it
|
// Line already present - delete it
|
||||||
jsr delete_line
|
jsr delete_line
|
||||||
jsr find_line // refresh OLDTXT
|
jsr find_line_from_start // refresh OLDTXT
|
||||||
!:
|
!:
|
||||||
// Insert new line if non-zero length, i.e., that
|
// Insert new line if non-zero length, i.e., that
|
||||||
// we are not just deleting the line.
|
// we are not just deleting the line.
|
||||||
|
|||||||
Reference in new issue
Block a user