separated commands from functions

This commit is contained in:
FeralChild64 committed 2020-06-08 18:26:38 +02:00
1 parent 5a2f847cb6
commit 0c8c0d6ad4
34 files changed
+215 -209

No files matched your search

@@ -3,13 +3,10 @@
// #LAYOUT# * * #IGNORE
//
// Jumptable for all known BASIC commands and functions
// Jumptable for all known BASIC commands
//
// XXX use separate jumptables for commands and functions
.const command_list = List().add(
// $80 - $8F
@@ -50,60 +47,24 @@
cmd_sys,
cmd_open,
// $A0-$A9
// $A0-$A6
cmd_close,
cmd_get,
cmd_new,
cmd_tab,
cmd_to,
cmd_fn,
cmd_spc,
cmd_then,
cmd_not,
cmd_step,
cmd_tab, // XXX this token probably does not belong here
do_SYNTAX_error, // 'TO' is not a standalone command
do_SYNTAX_error, // 'FN' is not a standalone command
cmd_spc, // XXX this token probably does not belong here
// 'THEN' ($A7) and 'STEP' ($A9) are not standalone commands
// 'NOT' ($A8) is an operator, not a command
// $CB, but remapped to $A9
// $CB, but remapped to $A7
cmd_go
)
/*
XXX we need a separate function dispatch table for the following ones:
// $B4-$BF
cmd_sgn,
cmd_int,
cmd_abs,
cmd_usr,
cmd_fre,
cmd_pos,
cmd_sqr,
cmd_rnd,
cmd_log,
cmd_exp,
cmd_cos,
cmd_sin,
// $C0-$CA
cmd_tan,
cmd_atn,
cmd_peek,
cmd_len,
cmd_str,
cmd_val,
cmd_asc,
cmd_chr,
cmd_left,
cmd_right,
cmd_mid
*/
#if !HAS_OPCODES_65C02
@@ -0,0 +1,65 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Default handler for all not-yet-implemented commands
//
// Note: NOPs are here just to make debugging easier (no duplicated labels)!
//
cmd_for:
nop
cmd_next:
nop
cmd_data:
nop
cmd_inputhash:
nop
cmd_input:
nop
cmd_dim:
nop
cmd_read:
nop
cmd_let:
nop
cmd_if:
nop
cmd_restore:
nop
cmd_gosub:
nop
cmd_return:
nop
cmd_on:
nop
cmd_wait:
nop
cmd_def:
nop
cmd_poke:
nop
cmd_printhash:
nop
cmd_cont:
nop
cmd_cmd:
nop
cmd_open:
nop
cmd_close:
nop
cmd_get:
nop
cmd_tab:
nop
cmd_spc:
nop
cmd_go:
nop
// Unimplemented tokens
jmp do_NOT_IMPLEMENTED_error
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,72 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Jumptable for all known BASIC functions
//
.const function_list = List().add(
// $B4-$BF
fun_sgn,
fun_int,
fun_abs,
fun_usr,
fun_fre,
fun_pos,
fun_sqr,
fun_rnd,
fun_log,
fun_exp,
fun_cos,
fun_sin,
// $C0-$CA
fun_tan,
fun_atn,
fun_peek,
fun_len,
fun_str,
fun_val,
fun_asc,
fun_chr,
fun_left,
fun_right,
fun_mid
)
#if !HAS_OPCODES_65C02
function_jumptable_lo:
put_jumptable_lo(function_list)
function_jumptable_hi:
put_jumptable_hi(function_list)
#else // HAS_OPCODES_65C02
__before_function_jumptable:
.if (mod(*, $2) == 1) { brk } // align code so that vector never crosses page boundary
function_jumptable:
put_jumptable(function_list)
// Make sure routine size is always the same - build system limitation
.if (__before_function_jumptable == function_jumptable) { brk }
#endif
@@ -0,0 +1,61 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Default handler for all not-yet-implemented functions
//
// Note: NOPs are here just to make debugging easier (no duplicated labels)!
//
fun_sgn:
nop
fun_int:
nop
fun_abs:
nop
fun_usr:
nop
fun_fre:
nop
fun_pos:
nop
fun_sqr:
nop
fun_rnd:
nop
fun_log:
nop
fun_exp:
nop
fun_cos:
nop
fun_sin:
nop
fun_tan:
nop
fun_atn:
nop
fun_peek:
nop
fun_len:
nop
fun_str:
nop
fun_val:
nop
fun_asc:
nop
fun_chr:
nop
fun_left:
nop
fun_right:
nop
fun_mid:
nop
// Unimplemented tokens
jmp do_NOT_IMPLEMENTED_error
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
-154
View File
@@ -1,154 +0,0 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Default handler for all not-yet-implemented commands
//
// Note: NOPs are here just to make debugging easier!
//
cmd_for:
nop
cmd_next:
nop
cmd_data:
nop
cmd_inputhash:
nop
cmd_input:
nop
cmd_dim:
nop
cmd_read:
nop
cmd_let:
nop
cmd_if:
nop
cmd_restore:
nop
cmd_gosub:
nop
cmd_return:
nop
// $90-$9F
cmd_on:
nop
cmd_wait:
nop
cmd_def:
nop
cmd_poke:
nop
cmd_printhash:
nop
cmd_cont:
nop
cmd_cmd:
nop
cmd_open:
nop
// $A0-$AF
cmd_close:
nop
cmd_get:
nop
cmd_tab:
nop
cmd_to:
nop
cmd_fn:
nop
cmd_spc:
nop
cmd_then:
nop
cmd_not:
nop
cmd_step:
nop
cmd_plus:
nop
cmd_minus:
nop
cmd_mult:
nop
cmd_div:
nop
cmd_exponent:
nop
cmd_and:
nop
// $B0-$BF
cmd_or:
nop
cmd_greater:
nop
cmd_equal:
nop
cmd_less:
nop
cmd_sgn:
nop
cmd_int:
nop
cmd_abs:
nop
cmd_usr:
nop
cmd_fre:
nop
cmd_pos:
nop
cmd_sqr:
nop
cmd_rnd:
nop
cmd_log:
nop
cmd_exp:
nop
cmd_cos:
nop
cmd_sin:
nop
// $C0-$CF
cmd_tan:
nop
cmd_atn:
nop
cmd_peek:
nop
cmd_len:
nop
cmd_str:
nop
cmd_val:
nop
cmd_asc:
nop
cmd_chr:
nop
cmd_left:
nop
cmd_right:
nop
cmd_mid:
nop
cmd_go:
nop
// Undefined tokens
cmd_unimplemented:
jmp do_NOT_IMPLEMENTED_error
+1 -1
View File
@@ -87,7 +87,7 @@ FRMEVL_loop:
FRMEVL_execute_function:
// XXX implement this
// XXX implement this - use function_jumptable*
jmp do_NOT_IMPLEMENTED_error
+3 -3
View File
@@ -32,7 +32,7 @@ execute_statements:
cmp #$7F
bcc_16 do_SYNTAX_error // branch if not a token XXX here we should handle variable assignments
cmp #$A9
cmp #$A6
bcs execute_statements_extended
execute_statements_run_token:
@@ -73,9 +73,9 @@ execute_statements_extended:
cmp #$CB
bne !+
// 'GO' command has a strande token, after functions
// 'GO' command has a strange token, after function tokens
lda #$A9
lda #$A7
bne execute_statements_run_token
!:
// XXX here is the place for possible extended BASIC command set