Update
This commit is contained in:
parent
fcc8379cc3
commit
7144eb4b24
3 changed files with 129 additions and 32 deletions
|
@ -3,8 +3,11 @@
|
|||
.include "$lib/core.asm"
|
||||
.include "$lib/std.asm"
|
||||
|
||||
.define PLACEHOLDER_U8, CORE_U8_MAX
|
||||
.define PLACEHOLDER_U16, CORE_U16_MAX
|
||||
|
||||
.define_eval prev, OFFSET
|
||||
ts CORE_U16_MAX
|
||||
ts PLACEHOLDER_U16
|
||||
tlr CORE_REG_PC
|
||||
.define_eval diff, (OFFSET - prev)
|
||||
.define_eval MAIN_JUMPER, (CORE_MEM_PRG_END - diff)
|
||||
|
@ -13,7 +16,7 @@
|
|||
|
||||
.define_eval prev, OFFSET
|
||||
{%- for c in conditions %}
|
||||
.bytes CORE_U16_MAX{% if !c.data.1.is_empty() %}, CORE_U16_MAX{% endif %}
|
||||
.bytes PLACEHOLDER_U16{% if !c.data.1.is_empty() %}, PLACEHOLDER_U16{% endif %}
|
||||
{%- endfor %}
|
||||
.define_eval JUMP_TABLE_CONDITIONS_SIZE, (OFFSET - prev)
|
||||
.org prev
|
||||
|
@ -35,6 +38,12 @@
|
|||
.define_eval counter, (counter + 2)
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
|
||||
; words
|
||||
{%- for w in words %}
|
||||
.define_eval jump_table_words_{{ w.id }}, (JUMP_TABLE_PTR + counter)
|
||||
.define_eval counter, (counter + 1)
|
||||
{%- endfor %}
|
||||
.delete counter
|
||||
|
||||
.define_eval MEM_JUMP_TABLE_LEN, (JUMP_TABLE_CONDITIONS_SIZE + JUMP_TABLE_WORDS_SIZE / 2)
|
||||
|
@ -58,29 +67,51 @@
|
|||
tlr CORE_REG_A
|
||||
.endmacro
|
||||
|
||||
.macro jump_table_pull_ptr, jump_table_pull_ptr_arg_0_ptr
|
||||
.std_get jump_table_pull_ptr_arg_0_ptr
|
||||
.macro jump_table_pull_ptr, jump_table_pull_ptr_arg_0_ptr, jump_table_pull_ptr_arg_1_counter
|
||||
ts jump_table_pull_ptr_arg_0_ptr
|
||||
tls
|
||||
|
||||
ts 8
|
||||
tlr CORE_REG_B
|
||||
.std_get jump_table_pull_ptr_arg_0_ptr
|
||||
tlr CORE_REG_A
|
||||
ts CORE_ALU_LSH
|
||||
alu
|
||||
tlr CORE_REG_A
|
||||
|
||||
.std_get (jump_table_pull_ptr_arg_0_ptr + 1)
|
||||
tlr CORE_REG_B
|
||||
ts CORE_ALU_OR
|
||||
alu
|
||||
tlr CORE_REG_A
|
||||
|
||||
tls
|
||||
dbg
|
||||
pop
|
||||
pop
|
||||
.endmacro
|
||||
|
||||
.define_eval counter, 0
|
||||
; setup jump table
|
||||
; conditions
|
||||
{%- for c in conditions %}
|
||||
; condition {{ c.id }}
|
||||
; if
|
||||
.jump_table_pull_ptr jump_table_conditions_if_{{ c.id }}
|
||||
.jump_table_pull_ptr jump_table_conditions_if_{{ c.id }}, counter
|
||||
.define_eval counter, (counter + 1)
|
||||
{%- if !c.data.1.is_empty() %}
|
||||
|
||||
; else
|
||||
.jump_table_pull_ptr jump_table_conditions_else_{{ c.id }}
|
||||
.jump_table_pull_ptr jump_table_conditions_else_{{ c.id }}, counter
|
||||
.define_eval counter, (counter + 1)
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
|
||||
; words
|
||||
{%- for w in words %}
|
||||
.jump_table_pull_ptr jump_table_words_{{ w.id }}, counter
|
||||
.define_eval counter, (counter + 1)
|
||||
{%- endfor %}
|
||||
.delete counter
|
||||
|
||||
.delete_macro jump_table_pull_ptr
|
||||
|
||||
.macro self_ref, self_ref_arg_0_ptr
|
||||
.std_rset CORE_REG_A, self_ref_arg_0_ptr
|
||||
.std_set self_ref_arg_0_ptr
|
||||
|
@ -144,13 +175,13 @@ return_call_stack_jump:
|
|||
.define_eval prev, OFFSET
|
||||
.std_ld
|
||||
tlr CORE_REG_A
|
||||
.std_rset CORE_REG_C, CORE_U16_MAX
|
||||
.std_rset CORE_REG_D, CORE_U16_MAX
|
||||
.std_rset CORE_REG_C, PLACEHOLDER_U16
|
||||
.std_rset CORE_REG_D, PLACEHOLDER_U16
|
||||
ts call_stack_jump
|
||||
tlrc CORE_REG_PC
|
||||
|
||||
.std_rset CORE_REG_C, CORE_U16_MAX
|
||||
.std_rset CORE_REG_D, CORE_U16_MAX
|
||||
.std_rset CORE_REG_C, PLACEHOLDER_U16
|
||||
.std_rset CORE_REG_D, PLACEHOLDER_U16
|
||||
ts call_stack_jump
|
||||
tlr CORE_REG_PC
|
||||
.define_eval CALL_STACK_JUMP_COND_IF_ELSE_SIZE, (OFFSET - prev)
|
||||
|
@ -230,6 +261,12 @@ return_call_stack_jump:
|
|||
.bytes conditions_else_{{ c.id }}
|
||||
{%- endif %}
|
||||
{% endfor %}
|
||||
|
||||
; words
|
||||
{%- for w in words %}
|
||||
.org jump_table_words_{{ w.id }}
|
||||
.bytes words_{{ w.id }}
|
||||
{% endfor %}
|
||||
.org prev
|
||||
.delete prev
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue