changed handling of external token lists

This commit is contained in:
FeralChild64 committed 2020-07-21 17:45:24 +02:00
1 parent 151b9440dd
commit 985a0882f6
29 files changed
+295 -316

No files matched your search

File renamed without changes.
@@ -4,6 +4,6 @@
// #LAYOUT# * * #IGNORE
packed_freq_keywords_CC:
packed_freq_keywords_01:
put_packed_freq_keywords_CC()
put_packed_freq_keywords_01()
@@ -3,7 +3,10 @@
// #LAYOUT# X16 BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
#if !HAS_SMALL_BASIC
packed_freq_keywords_CD:
packed_freq_keywords_02:
put_packed_freq_keywords_CD()
put_packed_freq_keywords_02()
#endif
@@ -0,0 +1,58 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Jumptable for BASIC commands with tokens prefixed by $01
//
.const command_01_list = List().add(
cmd_slow,
cmd_fast,
cmd_old,
// NOTE! These commands are temporarily placed here, they should be a part of list 02!
cmd_merge,
cmd_bload,
cmd_bsave,
cmd_bverify,
cmd_clear,
varstr_garbage_collect // cmd_dispose
)
#if !HAS_OPCODES_65C02
command_01_jumptable_lo:
put_jumptable_lo(command_01_list)
command_01_jumptable_hi:
put_jumptable_hi(command_01_list)
#else // HAS_OPCODES_65C02
__before_command_01_jumptable:
.if (mod(*, $2) == 1) { brk } // align code so that vector never crosses page boundary
command_01_jumptable:
put_jumptable(command_01_list)
// Make sure routine size is always the same - build system limitation
.if (__before_command_01_jumptable == command_01_jumptable) { brk }
#endif
File renamed without changes.
@@ -0,0 +1,60 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Jumptable for BASIC commands with tokens prefixed by $02
//
#if !HAS_SMALL_BASIC
.const command_02_list = List().add(
// NOTE! These commands are temporarily placed in list 01!
// cmd_merge,
// cmd_bload,
// cmd_bsave,
// cmd_bverify,
// cmd_clear,
// varstr_garbage_collect, // cmd_dispose
cmd_cold,
cmd_mem
)
#if !HAS_OPCODES_65C02
command_02_jumptable_lo:
put_jumptable_lo(command_02_list)
command_02_jumptable_hi:
put_jumptable_hi(command_02_list)
#else // HAS_OPCODES_65C02
__before_command_02_jumptable:
.if (mod(*, $2) == 1) { brk } // align code so that vector never crosses page boundary
command_02_jumptable:
put_jumptable(command_02_list)
// Make sure routine size is always the same - build system limitation
.if (__before_command_02_jumptable == command_02_jumptable) { brk }
#endif
#endif
File renamed without changes.
@@ -1,76 +0,0 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Jumptable for BASIC commands with tokens prefixed by $CC
//
#if !HAS_SMALL_BASIC
.const command_CC_list = List().add(
cmd_old,
cmd_merge,
cmd_bload,
cmd_bsave,
cmd_bverify,
cmd_clear,
varstr_garbage_collect, // cmd_dispose
cmd_cold,
cmd_mem
)
#else
.const command_CC_list = List().add(
cmd_old,
cmd_merge,
cmd_bload,
cmd_bsave,
cmd_bverify,
cmd_clear,
varstr_garbage_collect // cmd_dispose
)
#endif
#if !HAS_OPCODES_65C02
command_CC_jumptable_lo:
put_jumptable_lo(command_CC_list)
command_CC_jumptable_hi:
put_jumptable_hi(command_CC_list)
#else // HAS_OPCODES_65C02
__before_command_CC_jumptable:
.if (mod(*, $2) == 1) { brk } // align code so that vector never crosses page boundary
command_CC_jumptable:
put_jumptable(command_CC_list)
// Make sure routine size is always the same - build system limitation
.if (__before_command_CC_jumptable == command_CC_jumptable) { brk }
#endif
@@ -1,46 +0,0 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Jumptable for BASIC commands with tokens prefixed by $CD
//
.const command_CD_list = List().add(
cmd_slow,
cmd_fast
)
#if !HAS_OPCODES_65C02
command_CD_jumptable_lo:
put_jumptable_lo(command_CD_list)
command_CD_jumptable_hi:
put_jumptable_hi(command_CD_list)
#else // HAS_OPCODES_65C02
__before_command_CD_jumptable:
.if (mod(*, $2) == 1) { brk } // align code so that vector never crosses page boundary
command_CD_jumptable:
put_jumptable(command_CD_list)
// Make sure routine size is always the same - build system limitation
.if (__before_command_CD_jumptable == command_CD_jumptable) { brk }
#endif
+18 -10
View File
@@ -80,21 +80,25 @@ tokenise_line_loop:
// Check for extended tokens
lda #<packed_freq_keywords_CC
lda #<packed_freq_keywords_01
sta FRESPC+0
lda #>packed_freq_keywords_CC
lda #>packed_freq_keywords_01
sta FRESPC+1
jsr tk_search
bcc tokenise_line_keyword_CC // branch if keyword identified
bcc tokenise_line_keyword_01 // branch if keyword identified
lda #<packed_freq_keywords_CD
#if !HAS_SMALL_BASIC
lda #<packed_freq_keywords_02
sta FRESPC+0
lda #>packed_freq_keywords_CD
lda #>packed_freq_keywords_02
sta FRESPC+1
jsr tk_search
bcc tokenise_line_keyword_CD // branch if keyword identified
bcc tokenise_line_keyword_02 // branch if keyword identified
#endif
// Shorten packed keyword candidate and try again
@@ -169,20 +173,24 @@ tokenise_line_char:
// Support for extended keyword lists
tokenise_line_keyword_CC:
#if !HAS_SMALL_BASIC
tokenise_line_keyword_02:
// Store the token list index
lda #$CC
lda #$02
skip_2_bytes_trash_nvz
// FALLTROUGH
tokenise_line_keyword_CD:
#endif
tokenise_line_keyword_01:
// Store the token list index
lda #$CD
lda #$01
ldy tk__offset
sta BUF, y
@@ -39,12 +39,24 @@ execute_statements:
// Check if token is valid for execution
#if HAS_SMALL_BASIC
cpx #$01
beq execute_statements_01
#else
cpx #$03
bcc execute_statements_extended
#endif
cpx #$CB
beq_16 cmd_go // // 'GO' command has a strange token, placed after function tokens
cpx #$7F
bcc_16 execute_statements_var_assign // not a token - try variable assign
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.
@@ -67,25 +79,25 @@ execute_statements:
#endif
#if !HAS_SMALL_BASIC
execute_statements_extended:
// Support for extended BASIC commands
cpx #$CC
beq execute_statements_CC
cpx #$CD
beq execute_statements_CD
// XXX consider jumpable here
// 'GO' command has a strange token, it is placed after function tokens
cpx #$01
beq execute_statements_01
cpx #$CB
beq_16 cmd_go
cpx #$02
beq execute_statements_02
jmp do_SYNTAX_error
#endif
execute_statements_CC:
execute_statements_01:
// Get the sub-token, check that it is valid
@@ -93,7 +105,7 @@ execute_statements_CC:
cmp #$00
beq_16 do_SYNTAX_error
cmp #(TK__MAXTOKEN_keywords_CC+1)
cmp #(TK__MAXTOKEN_keywords_01+1)
bcs_16 do_SYNTAX_error
// Execute command
@@ -103,9 +115,9 @@ execute_statements_CC:
// Get the jump table entry for it, push it on the stack, and then RTS to start it.
tax
lda command_CC_jumptable_hi - 1, x
lda command_01_jumptable_hi - 1, x
pha
lda command_CC_jumptable_lo - 1, x
lda command_01_jumptable_lo - 1, x
pha
rts
@@ -116,12 +128,13 @@ execute_statements_CC:
asl
tax
jmp (command_CC_jumptable - 2, x)
jmp (command_01_jumptable - 2, x)
#endif
#if !HAS_SMALL_BASIC
execute_statements_CD:
execute_statements_02:
// Get the sub-token, check that it is valid
@@ -129,7 +142,7 @@ execute_statements_CD:
cmp #$00
beq_16 do_SYNTAX_error
cmp #(TK__MAXTOKEN_keywords_CD+1)
cmp #(TK__MAXTOKEN_keywords_02+1)
bcs_16 do_SYNTAX_error
// Execute command
@@ -139,9 +152,9 @@ execute_statements_CD:
// Get the jump table entry for it, push it on the stack, and then RTS to start it.
tax
lda command_CD_jumptable_hi - 1, x
lda command_02_jumptable_hi - 1, x
pha
lda command_CD_jumptable_lo - 1, x
lda command_02_jumptable_lo - 1, x
pha
rts
@@ -152,10 +165,11 @@ execute_statements_CD:
asl
tax
jmp (command_CD_jumptable - 2, x)
jmp (command_02_jumptable - 2, x)
#endif
#endif // !HAS_SMALL_BASIC
execute_statements_end_of_line:
+74 -78
View File
@@ -79,6 +79,7 @@ list_print_loop:
jmp list_is_literal
list_not_quote:
// Check quote mode, and display as literal if required
ldx QTSW
bne list_is_literal
@@ -86,87 +87,19 @@ list_not_quote:
cmp #$FF
beq list_is_pi
// Check for extended BASIC tokens
cmp #$01
beq list_display_token_01
#if !HAS_SMALL_BASIC
cmp #$02
beq list_display_token_02
#endif
// Check for literals
cmp #$7F
bcc list_is_literal
// Display a token
list_display_token_CC:
cmp #$CC
bne list_display_token_CD
// Fetch the sub-token
iny
#if ROM_LAYOUT_M65
jsr peek_via_OLDTXT
#elif CONFIG_MEMORY_MODEL_60K
ldx #<OLDTXT
jsr peek_under_roms
cmp #$00
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
jsr peek_under_roms_via_OLDTXT
cmp #$00
#else // CONFIG_MEMORY_MODEL_38K
lda (OLDTXT),y
#endif
// Save registers
tax
pha
phy_trash_a
// Subtract $1 from token to get offset in token list
dex
// Check if token is known
cpx #TK__MAXTOKEN_keywords_CC
bcs list_display_unknown_token // XXX consider displaying two question marks here
// Now ask for it to be printed
jsr print_packed_keyword_CC
jmp_8 list_token_displayed
list_display_token_CD:
cmp #$CD
bne list_display_token_V2
// Fetch the sub-token
iny
#if ROM_LAYOUT_M65
jsr peek_via_OLDTXT
#elif CONFIG_MEMORY_MODEL_60K
ldx #<OLDTXT
jsr peek_under_roms
cmp #$00
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
jsr peek_under_roms_via_OLDTXT
cmp #$00
#else // CONFIG_MEMORY_MODEL_38K
lda (OLDTXT),y
#endif
// Save registers
tax
pha
phy_trash_a
// Subtract $1 from token to get offset in token list
dex
// Check if token is known
cpx #TK__MAXTOKEN_keywords_CD
bcs list_display_unknown_token // XXX consider displaying two question marks here
// Now ask for it to be printed
jsr print_packed_keyword_CD
jmp_8 list_token_displayed
// Display a token - V2 dialect
list_display_token_V2:
@@ -254,4 +187,67 @@ list_display_unknown_token:
jmp_8 list_is_unknown
list_display_token_01:
// Display a 2-byte token - for extended BASIC
jsr list_fetch_subtoken
// Check if token is known
cpx #TK__MAXTOKEN_keywords_01
bcs list_is_unknown // XXX consider displaying two question marks here, not one
// Now ask for it to be printed
phy_trash_a
jsr print_packed_keyword_01
ply_trash_a
// Next iteration
jmp list_print_loop
#if !HAS_SMALL_BASIC
list_display_token_02:
// Display a 2-byte token - for extended BASIC
jsr list_fetch_subtoken
// Check if token is known
cpx #TK__MAXTOKEN_keywords_02
bcs list_is_unknown // XXX consider displaying two question marks here, not one
// Now ask for it to be printed
phy_trash_a
jsr print_packed_keyword_02
ply_trash_a
// Next iteration
jmp list_print_loop
#endif
list_fetch_subtoken:
// Fetch the sub-token
iny
#if ROM_LAYOUT_M65
jsr peek_via_OLDTXT
#elif CONFIG_MEMORY_MODEL_60K
ldx #<OLDTXT
jsr peek_under_roms
cmp #$00
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
jsr peek_under_roms_via_OLDTXT
cmp #$00
#else // CONFIG_MEMORY_MODEL_38K
lda (OLDTXT),y
#endif
// Subtract $1 from token to get offset in token list
tax
dex
rts
#endif // ROM layout
+10 -6
View File
@@ -39,18 +39,22 @@ print_packed_misc_str: // .X - misc string index
#endif
print_packed_keyword_CC: // .X - token number
print_packed_keyword_01: // .X - token number
lda #<packed_freq_keywords_CC
ldy #>packed_freq_keywords_CC
lda #<packed_freq_keywords_01
ldy #>packed_freq_keywords_01
bne print_freq_packed_string // branch always
print_packed_keyword_CD: // .X - token number
#if !HAS_SMALL_BASIC
lda #<packed_freq_keywords_CD
ldy #>packed_freq_keywords_CD
print_packed_keyword_02: // .X - token number
lda #<packed_freq_keywords_02
ldy #>packed_freq_keywords_02
bne print_freq_packed_string // branch always
#endif
print_packed_keyword_V2: // .X - token number
lda #<packed_freq_keywords_V2