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:
|
||||
|
||||
// RUN clears all variables
|
||||
|
||||
jsr do_clr
|
||||
|
||||
cmd_goto:
|
||||
// Initialize OLDTXT pointer, disable Kernal messages
|
||||
|
||||
// XXX optimize this: deduplicate last part (and init_oldtxt) with load/verify,
|
||||
// if line number greater than current line - find line backwards
|
||||
|
||||
// Disable Kernal messages
|
||||
jsr init_oldtxt
|
||||
lda #$00
|
||||
jsr JSETMSG
|
||||
|
||||
// Reset line pointer to first line of program.
|
||||
jsr init_oldtxt
|
||||
// Check if we have any paramenters
|
||||
|
||||
jsr is_end_of_statement
|
||||
bcs !+
|
||||
bcs cmd_run_goto_launch
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
cmd_goto:
|
||||
|
||||
// GOTO requires line number
|
||||
|
||||
jsr fetch_line_number
|
||||
bcs_16 do_SYNTAX_error
|
||||
jsr find_line
|
||||
bcc !+
|
||||
// Line does not exist, so report error
|
||||
jmp do_UNDEFD_STATEMENT_error
|
||||
|
||||
// Check for direct mode
|
||||
|
||||
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!
|
||||
|
||||
|
||||
pha
|
||||
pha
|
||||
jmp execute_line
|
||||
Reference in new issue
Block a user