more size optimizations in BASIC interpreter

This commit is contained in:
FeralChild64 committed 2020-07-09 22:58:15 +02:00
1 parent 4871abd79b
commit dbd8c77751
22 files changed
+67 -61

No files matched your search

+2 -2
View File
@@ -23,7 +23,7 @@
cmd_goto,
cmd_run,
cmd_if,
cmd_restore,
do_restore, // cmd_restore
cmd_gosub,
cmd_return,
cmd_rem,
@@ -42,7 +42,7 @@
cmd_print,
cmd_cont,
cmd_list,
cmd_clr,
do_clr, // cmd_clr
cmd_cmd,
cmd_sys,
cmd_open,
+2 -6
View File
@@ -3,10 +3,6 @@
// #LAYOUT# * * #IGNORE
cmd_clr:
// PLACEHOLDER for completeness - jumptable contains direct address
jsr do_clr
// CLR command does not stop execution (confirmed on a C64)
jmp end_of_statement
// CLR command does not stop execution (confirmed on a C64)
+1 -1
View File
@@ -31,7 +31,7 @@ list_loop:
// LIST terminates any running program,
// because it has fiddled with the current line pointer.
// (Confirmed by testing on a C64)
jmp shell_main_loop
jmp end_of_program
list_more_lines:
+4 -5
View File
@@ -74,10 +74,9 @@ cmd_load_no_error:
ldx CURLIN+1
inx
beq cmd_load_end // branch if direct mode
beq_16 end_of_program // branch if direct mode
pha
pha
jmp execute_line
cmd_load_end:
jmp shell_main_loop
+1 -1
View File
@@ -9,4 +9,4 @@ cmd_new:
// NEW command terminates execution (confirmed on a C64)
jmp shell_main_loop
jmp end_of_program
+1 -1
View File
@@ -91,4 +91,4 @@ cmd_print_done:
// Execute next statement
jmp end_of_statement
rts
+2
View File
@@ -7,4 +7,6 @@
cmd_rem:
pha
pha
jmp execute_statements_end_of_line
+2 -6
View File
@@ -3,10 +3,6 @@
// #LAYOUT# * * #IGNORE
cmd_restore:
// PLACEHOLDER for completeness - jumptable contains direct address
jsr do_restore
// RESTORE command does not stop execution (confirmed on a C64)
jmp end_of_statement
// RESTORE command does not stop execution (confirmed on a C64)
+9
View File
@@ -4,9 +4,15 @@
cmd_run:
// RUN clears all variables
jsr do_clr
cmd_goto:
// 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
lda #$00
jsr JSETMSG
@@ -24,4 +30,7 @@ cmd_goto:
jmp do_UNDEFD_STATEMENT_error
!:
// Run it!
pha
pha
jmp execute_line
+1 -1
View File
@@ -40,4 +40,4 @@ cmd_save_do: // entry point for BSAVE
// Execute next statement
jmp end_of_statement
rts
+1 -1
View File
@@ -27,4 +27,4 @@ cmd_stop:
cmd_end:
jmp shell_main_loop
jmp end_of_program
+1 -4
View File
@@ -60,10 +60,7 @@ cmd_sys_setup_call:
plp
// Call the routine.
jsr USRPOK
jmp end_of_statement
jmp USRPOK
//
// XXX Temporary ugly hack to support 'SYS PI*656'
@@ -19,7 +19,7 @@
cmd_cold,
cmd_clear,
cmd_dispose
varstr_garbage_collect // cmd_dispose
)
@@ -39,4 +39,4 @@ cmd_bload:
// Execute next statement
jmp end_of_statement
rts
+2 -5
View File
@@ -5,9 +5,6 @@
cmd_clear:
jsr clear_screen
// Execute next statement
jmp end_of_statement
// XXX in the future add separate implementation for graphics screen
jmp clear_screen
+3 -1
View File
@@ -6,7 +6,9 @@
cmd_cold:
jsr helper_ask_if_sure
bcs_16 end_of_statement
bcs !+
jsr JCLALL // for extra safety
jmp (vector_reset) // hardware CPU vector
!:
rts
+1 -8
View File
@@ -3,11 +3,4 @@
// #LAYOUT# * * #IGNORE
cmd_dispose:
jsr varstr_garbage_collect
// Execute next statement
jmp end_of_statement
// PLACEHOLDER for completeness - jumptable contains direct address
+2 -6
View File
@@ -42,10 +42,6 @@ cmd_merge_got_params:
cmd_merge_no_error:
// Relink loaded program, clear variables
// Relink loaded program, clear variables, execute next statement
jsr update_LINKPRG_VARTAB_do_clr
// Execute next statement
jmp end_of_statement
jmp update_LINKPRG_VARTAB_do_clr
+1 -1
View File
@@ -21,4 +21,4 @@ cmd_old:
// Quit
jmp shell_main_loop
jmp end_of_program
+5 -5
View File
@@ -20,7 +20,7 @@ cmd_fast:
lda #$41
sta CPU_D6510
jmp end_of_statement
rts
#elif CONFIG_MB_ULTIMATE_64
@@ -30,12 +30,12 @@ cmd_fast:
cmd_slow:
sta SCPU_SPEED_NORMAL
jmp end_of_statement
rts
cmd_fast:
sta SCPU_SPEED_TURBO
jmp end_of_statement
rts
#elif CONFIG_PLATFORM_COMMODORE_64
@@ -60,13 +60,13 @@ cmd_fast:
lda #$01
!:
sta VIC_CLKRATE
jmp end_of_statement
rts
#else
cmd_slow:
nop // to prevent double label
nop // just to prevent double label
// FALLTROUGH
+8
View File
@@ -3,6 +3,14 @@
// #LAYOUT# * * #IGNORE
end_of_program:
// Entry point for commands not wishing to continue
pha
pha
// FALLTROUGH
shell_main_loop:
// Tell user we are ready
+16 -5
View File
@@ -42,14 +42,24 @@ execute_statements:
cmp #$7F
bcc_16 execute_statements_var_assign // not a token - try variable assign
cmp #$A6
// Move token code to .X
tax
// A token - first push the 'end_of_statement' address for RTS
lda #>(end_of_statement - 1)
pha
lda #<(end_of_statement - 1)
pha
cpx #$A6
bcs execute_statements_extended
#if !HAS_OPCODES_65C02
// Get the jump table entry for it, push it on the stack, and then RTS to start it.
tax
lda command_jumptable_hi - $80, x
pha
lda command_jumptable_lo - $80, x
@@ -61,6 +71,7 @@ execute_statements:
// Use jumptable to go to the command routine
txa
asl
tax
jmp (command_jumptable, x)
@@ -72,14 +83,14 @@ execute_statements_extended:
// Support for extended BASIC commands
cmp #$CC
cpx #$CC
beq execute_statements_CC
cmp #$CD
cpx #$CD
beq execute_statements_CD
// 'GO' command has a strange token, it is placed after function tokens
cmp #$CB
cpx #$CB
beq_16 cmd_go
jmp do_SYNTAX_error