Update WIP with jump table for words and conditions

This commit is contained in:
Dominic Grimm 2023-04-02 12:39:35 +02:00
parent df73353bc6
commit 00bab636db
No known key found for this signature in database
GPG key ID: 12EFFCAEA9E620BF
10 changed files with 234 additions and 116 deletions

View file

@ -2,9 +2,10 @@
{% if name.starts_with('"') %}{{ name }}{% else %}"{{ name }}"{% endif %}
{%- endmacro -%}
; Generated by Henceforth {{ env!("CARGO_PKG_VERSION") }} ({{ env!("CARGO_PKG_REPOSITORY") }})
.include "$lib/core.asm"
.include "$lib/std.asm"
;.include "$lib/main.asm"
.define_eval prev, OFFSET
ts CORE_U16_MAX
@ -14,7 +15,21 @@
.org prev
.delete prev, diff
.define_eval MAIN_JUMPER, (CORE_MEM_PRG_END - 3 - 1)
.define_eval prev, OFFSET
{%- for c in conditions %}
.bytes NULL
{% if !c.data.1.is_empty() %}.bytes NULL{% endif %}
{% endfor %}
.define_eval INDEX_CONDITIONS_SIZE, (OFFSET - prev)
.org prev
.delete prev
.debug INDEX_CONDITIONS_SIZE
; index
{%- for c in conditions %}
index_conditions_if_{{ c.id }}:
{% endfor %}
.define_eval MEM_LOOP_DEPTH, CORE_MEM_MEM
.define_eval MEM_LOOP_I, (MEM_LOOP_DEPTH + 1)
@ -70,20 +85,50 @@ return_call_stack_jump:
get
tlr CORE_REG_PC
.macro call_stack_jump, call_stack_jump_arg_0_label, call_stack_jump_arg_1_offset
.std_rset CORE_REG_C, call_stack_jump_arg_0_label
.std_rset CORE_REG_D, (call_stack_jump_arg_1_offset + 7)
.define_eval prev, OFFSET
.std_rset CORE_REG_C, CORE_U16_MAX
.std_rset CORE_REG_D, CORE_U16_MAX
ts call_stack_jump
tlr CORE_REG_PC
.define_eval CALL_STACK_JUMP_SIZE, (OFFSET - prev)
.org prev
.delete prev
.macro call_stack_jump, call_stack_jump_arg_0_label
.define_eval prev, OFFSET
.define offset_till_end, (OFFSET - prev * -1 + CALL_STACK_JUMP_COND_IF_ELSE_SIZE)
.std_rset CORE_REG_C, call_stack_jump_arg_0_label
.std_rset CORE_REG_D, (OFFSET + offset_till_end)
ts call_stack_jump
tlr CORE_REG_PC
.delete prev, offset_till_end
.endmacro
.macro call_stack_jump_cond_if, call_stack_jump_cond_if_arg_0_if_label, call_stack_jump_cond_if_arg_1_offset
.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
ts call_stack_jump
tlrc CORE_REG_PC
.define_eval CALL_STACK_JUMP_COND_IF_SIZE, (OFFSET - prev)
.org prev
.delete prev
.macro call_stack_jump_cond_if, call_stack_jump_cond_if_arg_0_if_label
.define_eval prev, OFFSET
.define offset_till_end, (OFFSET - prev * -1 + CALL_STACK_JUMP_COND_IF_ELSE_SIZE)
.std_ld
tlr CORE_REG_A
.std_rset CORE_REG_C, call_stack_jump_cond_if_arg_0_if_label
.std_rset CORE_REG_D, (call_stack_jump_cond_if_arg_1_offset + 7)
.std_rset CORE_REG_D, (OFFSET + offset_till_end)
ts call_stack_jump
tlrc CORE_REG_PC
.delete prev, offset_till_end
.endmacro
.define_eval prev, OFFSET
@ -99,24 +144,26 @@ return_call_stack_jump:
ts call_stack_jump
tlr CORE_REG_PC
.define_eval CALL_STACK_JUMP_COND_IF_ELSE_SIZE, (OFFSET - prev)
.org prev
.delete prev
.macro call_stack_jump_cond_if_else, call_stack_jump_cond_if_else_arg_0_if_label, call_stack_jump_cond_if_else_arg_1_else_label, call_stack_jump_cond_if_else_arg_2_offset
.macro call_stack_jump_cond_if_else, call_stack_jump_cond_if_else_arg_0_if_label, call_stack_jump_cond_if_else_arg_1_else_label
.define_eval prev, OFFSET
.define offset_till_end, (OFFSET - prev * -1 + CALL_STACK_JUMP_COND_IF_ELSE_SIZE)
.std_ld
tlr CORE_REG_A
.std_rset CORE_REG_C, call_stack_jump_cond_if_else_arg_0_if_label
.std_rset CORE_REG_D, (call_stack_jump_cond_if_else_arg_2_offset)
.std_rset CORE_REG_D, (OFFSET + offset_till_end)
ts call_stack_jump
tlrc CORE_REG_PC
.std_rset CORE_REG_C, call_stack_jump_cond_if_else_arg_1_else_label
.std_rset CORE_REG_D, (call_stack_jump_cond_if_else_arg_2_offset + 11)
.std_rset CORE_REG_D, (OFFSET + offset_till_end)
ts call_stack_jump
tlr CORE_REG_PC
.delete prev
.delete prev, offset_till_end
.endmacro
.macro return_call_stack_jump
@ -147,7 +194,7 @@ return_call_stack_jump:
.return_call_stack_jump
conditions_else_{{ c.id }}:
{%- for ins in c.data.0 %}
{%- for ins in c.data.1 %}
{{ ins }}
{%- endfor %}
.return_call_stack_jump