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