This commit is contained in:
Dominic Grimm 2023-04-02 14:32:11 +02:00
parent 00bab636db
commit 3da2567890
Signed by: dergrimm
GPG key ID: 12EFFCAEA9E620BF
3 changed files with 75 additions and 67 deletions

View file

@ -11,21 +11,36 @@
.org prev
.delete prev, diff
.define_eval prev, OFFSET
.bytes NULL
.bytes NULL
; .define_eval prev, OFFSET
;
; .bytes CORE_U16_MAX, CORE_U16_MAX
;
; .define_eval JUMP_TABLE_CONDITIONS_SIZE, (OFFSET - prev)
; .org prev
; .delete prev
.define_eval INDEX_CONDITIONS_SIZE, (OFFSET - prev)
.org prev
.delete prev
; .define_eval JUMP_TABLE_WORDS_SIZE, (0 * 2)
.debug INDEX_CONDITIONS_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)
; index
index_conditions_if_0:
; .debug MEM_JUMP_TABLE_LEN, MEM_JUMP_TABLE_PTR, MEM_JUMP_TABLE_END
; ; jump table
; ; conditions
;
; jump_table_conditions_if_0: .bytes 444
;
; jump_table_conditions_else_0: .bytes 5498
;
;
.define_eval MEM_LOOP_DEPTH, CORE_MEM_MEM
.define_eval MEM_JUMP_TABLE_LEN, 9
.define_eval MEM_JUMP_TABLE_PTR, CORE_MEM_MEM
.define_eval MEM_JUMP_TABLE_END, (MEM_JUMP_TABLE_PTR + MEM_JUMP_TABLE_LEN)
.define_eval MEM_LOOP_DEPTH, (MEM_JUMP_TABLE_END + 1)
.define_eval MEM_LOOP_I, (MEM_LOOP_DEPTH + 1)
.define_eval MEM_LOOP_J, (MEM_LOOP_I + 1)
@ -42,9 +57,14 @@
tlr CORE_REG_A
.endmacro
; setup jump table
; reference MEM_CALL_STACK_PTR to itself
.std_rset CORE_REG_A, MEM_CALL_STACK_PTR
.std_set MEM_CALL_STACK_PTR
; reference MEM_ALLOC_PTR to itself
.std_rset CORE_REG_A, MEM_ALLOC_PTR
.std_set MEM_ALLOC_PTR
@ -176,11 +196,6 @@ return_call_stack_jump:
.std_set CORE_MEM_OUT
.std_rset CORE_REG_A, '\n'
.std_set CORE_MEM_CHR
.call_stack_jump words_0
.call_stack_jump words_1
.call_stack_jump words_2
.call_stack_jump words_3
.call_stack_jump words_4
dbg
.return_call_stack_jump
@ -195,38 +210,6 @@ return_call_stack_jump:
; words
words_0:
; name : "test"
push 40
push 2
.stack_transfer_alu
.std_alu CORE_ALU_ADD
tls
.return_call_stack_jump
words_1:
; name : "meep"
push 32
.return_call_stack_jump
words_2:
; name : "morp"
push 4875
push 8748
dbg
.return_call_stack_jump
words_3:
; name : "zeep"
push 8777
dbg
.return_call_stack_jump
words_4:
; name : "borg"
dbg
.return_call_stack_jump
; main
main:
@ -237,11 +220,18 @@ main:
.org main
push 0
.call_stack_jump_cond_if_else conditions_if_0, conditions_else_0
.call_stack_jump words_0
push 40
push 2
.stack_transfer_alu
.std_alu CORE_ALU_ADD
tls
dbg
push 32
push 4875
push 8748
dbg
push 8777
dbg
dbg
.call_stack_jump words_1
.call_stack_jump words_2
.call_stack_jump words_3
.call_stack_jump words_4
dbg
.std_stop

View file

@ -6,5 +6,5 @@
\ 42 42 = debug if 69 . else 420 . then cr
0 if 42 . cr test meep morp zeep borg debug else 69 . cr then
0 if 42 . cr debug else 69 . cr then
test debug meep morp zeep borg debug

View file

@ -15,23 +15,36 @@
.org prev
.delete prev, diff
.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
; .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
.debug INDEX_CONDITIONS_SIZE
; .define_eval JUMP_TABLE_WORDS_SIZE, ({{ words.len() }} * 2)
; index
{%- for c in conditions %}
index_conditions_if_{{ c.id }}:
{% endfor %}
; .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)
.define_eval MEM_LOOP_DEPTH, CORE_MEM_MEM
; .debug MEM_JUMP_TABLE_LEN, MEM_JUMP_TABLE_PTR, MEM_JUMP_TABLE_END
; ; 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_PTR, CORE_MEM_MEM
.define_eval MEM_JUMP_TABLE_END, (MEM_JUMP_TABLE_PTR + MEM_JUMP_TABLE_LEN)
.define_eval MEM_LOOP_DEPTH, (MEM_JUMP_TABLE_END + 1)
.define_eval MEM_LOOP_I, (MEM_LOOP_DEPTH + 1)
.define_eval MEM_LOOP_J, (MEM_LOOP_I + 1)
@ -48,9 +61,14 @@
tlr CORE_REG_A
.endmacro
; setup jump table
; reference MEM_CALL_STACK_PTR to itself
.std_rset CORE_REG_A, MEM_CALL_STACK_PTR
.std_set MEM_CALL_STACK_PTR
; reference MEM_ALLOC_PTR to itself
.std_rset CORE_REG_A, MEM_ALLOC_PTR
.std_set MEM_ALLOC_PTR