Update assembly template

This commit is contained in:
Dominic Grimm 2023-04-03 11:42:45 +02:00
parent 3da2567890
commit 7d96943862
No known key found for this signature in database
GPG key ID: 12EFFCAEA9E620BF
3 changed files with 79 additions and 74 deletions

View file

@ -15,32 +15,33 @@
.org prev
.delete prev, diff
; .define_eval prev, OFFSET
; {%- for c in conditions %}
; .bytes CORE_U16_MAX{% if !c.data.1.is_empty() %}, CORE_U16_MAX{% endif %}
; {%- endfor %}
; .define_eval JUMP_TABLE_CONDITIONS_SIZE, (OFFSET - prev)
; .org prev
; .delete prev
.define_eval prev, OFFSET
{%- for c in conditions %}
.bytes CORE_U16_MAX{% if !c.data.1.is_empty() %}, CORE_U16_MAX{% endif %}
{%- endfor %}
.define_eval JUMP_TABLE_CONDITIONS_SIZE, (OFFSET - prev)
.org prev
.delete prev
; .define_eval JUMP_TABLE_WORDS_SIZE, ({{ words.len() }} * 2)
.define_eval JUMP_TABLE_WORDS_SIZE, ({{ words.len() }} * 2)
.define_eval JUMP_TABLE_PTR, (MAIN_JUMPER - JUMP_TABLE_CONDITIONS_SIZE - JUMP_TABLE_WORDS_SIZE)
; .define_eval MEM_JUMP_TABLE_LEN, (JUMP_TABLE_CONDITIONS_SIZE + JUMP_TABLE_WORDS_SIZE / 2)
; .define_eval MEM_JUMP_TABLE_PTR, CORE_MEM_MEM
; .define_eval MEM_JUMP_TABLE_END, (MEM_JUMP_TABLE_PTR + MEM_JUMP_TABLE_LEN)
.debug JUMP_TABLE_CONDITIONS_SIZE, JUMP_TABLE_WORDS_SIZE, (JUMP_TABLE_CONDITIONS_SIZE + JUMP_TABLE_WORDS_SIZE / 2), JUMP_TABLE_PTR
; .debug MEM_JUMP_TABLE_LEN, MEM_JUMP_TABLE_PTR, MEM_JUMP_TABLE_END
.define_eval counter, 0
; jump table
; conditions
{%- for c in conditions %}
.define_eval jump_table_conditions_if_{{ c.id }}, (JUMP_TABLE_PTR + counter)
.define_eval counter, (counter + 2)
{%- if !c.data.1.is_empty() %}
.define_eval jump_table_conditions_else_{{ c.id }}, (JUMP_TABLE_PTR + counter)
.define_eval counter, (counter + 2)
{%- endif %}
{%- endfor %}
.delete counter
; ; jump table
; ; conditions
; {%- for c in conditions %}
; jump_table_conditions_if_{{ c.id }}: .bytes 444
; {%- if !c.data.1.is_empty() %}
; jump_table_conditions_else_{{ c.id }}: .bytes 5498
; {%- endif %}
; {%- endfor %}
.define_eval MEM_JUMP_TABLE_LEN, 9
.define_eval MEM_JUMP_TABLE_LEN, (JUMP_TABLE_CONDITIONS_SIZE + JUMP_TABLE_WORDS_SIZE / 2)
.define_eval MEM_JUMP_TABLE_PTR, CORE_MEM_MEM
.define_eval MEM_JUMP_TABLE_END, (MEM_JUMP_TABLE_PTR + MEM_JUMP_TABLE_LEN)
@ -62,7 +63,17 @@
.endmacro
; setup jump table
; conditions
{%- for c in conditions %}
; condition {{ c.id }}
.std_get jump_table_conditions_if_{{ c.id }}
tls
.std_get (jump_table_conditions_if_{{ c.id }} + 1)
tls
dbg
pop
pop
{%- endfor %}
; reference MEM_CALL_STACK_PTR to itself
.std_rset CORE_REG_A, MEM_CALL_STACK_PTR
@ -229,6 +240,12 @@ return_call_stack_jump:
.return_call_stack_jump
{% endfor %}
.define_eval prev, OFFSET
.org JUMP_TABLE_PTR
.org prev
.delete prev
; main
main:
.org MAIN_JUMPER