Update assembly template
This commit is contained in:
parent
3da2567890
commit
7d96943862
3 changed files with 79 additions and 74 deletions
|
@ -11,32 +11,27 @@
|
|||
.org prev
|
||||
.delete prev, diff
|
||||
|
||||
; .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 prev, OFFSET
|
||||
.bytes CORE_U16_MAX, CORE_U16_MAX
|
||||
.define_eval JUMP_TABLE_CONDITIONS_SIZE, (OFFSET - prev)
|
||||
.org prev
|
||||
.delete prev
|
||||
|
||||
; .define_eval JUMP_TABLE_WORDS_SIZE, (0 * 2)
|
||||
.define_eval JUMP_TABLE_WORDS_SIZE, (0 * 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
|
||||
.define_eval jump_table_conditions_if_0, (JUMP_TABLE_PTR + counter)
|
||||
.define_eval counter, (counter + 2)
|
||||
.define_eval jump_table_conditions_else_0, (JUMP_TABLE_PTR + counter)
|
||||
.define_eval counter, (counter + 2)
|
||||
.delete counter
|
||||
|
||||
; ; jump table
|
||||
; ; conditions
|
||||
;
|
||||
; jump_table_conditions_if_0: .bytes 444
|
||||
;
|
||||
; jump_table_conditions_else_0: .bytes 5498
|
||||
;
|
||||
;
|
||||
|
||||
.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)
|
||||
|
||||
|
@ -58,7 +53,14 @@
|
|||
.endmacro
|
||||
|
||||
; setup jump table
|
||||
|
||||
; condition 0
|
||||
.std_get jump_table_conditions_if_0
|
||||
tls
|
||||
.std_get (jump_table_conditions_if_0 + 1)
|
||||
tls
|
||||
dbg
|
||||
pop
|
||||
pop
|
||||
|
||||
; reference MEM_CALL_STACK_PTR to itself
|
||||
.std_rset CORE_REG_A, MEM_CALL_STACK_PTR
|
||||
|
@ -190,22 +192,17 @@ return_call_stack_jump:
|
|||
; conditions
|
||||
; condition: 0
|
||||
conditions_if_0:
|
||||
push 42
|
||||
.std_ld
|
||||
tlr CORE_REG_A
|
||||
.std_set CORE_MEM_OUT
|
||||
.std_rset CORE_REG_A, '\n'
|
||||
.std_set CORE_MEM_CHR
|
||||
dbg
|
||||
.return_call_stack_jump
|
||||
|
||||
conditions_else_0:
|
||||
push 69
|
||||
.std_ld
|
||||
tlr CORE_REG_A
|
||||
.std_set CORE_MEM_OUT
|
||||
.std_rset CORE_REG_A, '\n'
|
||||
.std_set CORE_MEM_CHR
|
||||
.return_call_stack_jump
|
||||
|
||||
conditions_else_0:
|
||||
push 420
|
||||
.std_ld
|
||||
tlr CORE_REG_A
|
||||
.std_set CORE_MEM_OUT
|
||||
.return_call_stack_jump
|
||||
|
||||
|
||||
|
@ -218,20 +215,13 @@ main:
|
|||
tlr CORE_REG_PC
|
||||
|
||||
.org main
|
||||
push 0
|
||||
.call_stack_jump_cond_if_else conditions_if_0, conditions_else_0
|
||||
push 40
|
||||
push 2
|
||||
push 42
|
||||
tls
|
||||
.stack_transfer_alu
|
||||
.std_alu CORE_ALU_ADD
|
||||
.std_alu CORE_ALU_EQ
|
||||
tls
|
||||
dbg
|
||||
push 32
|
||||
push 4875
|
||||
push 8748
|
||||
dbg
|
||||
push 8777
|
||||
dbg
|
||||
dbg
|
||||
dbg
|
||||
.call_stack_jump_cond_if_else conditions_if_0, conditions_else_0
|
||||
.std_rset CORE_REG_A, '\n'
|
||||
.std_set CORE_MEM_CHR
|
||||
.std_stop
|
||||
|
|
|
@ -4,7 +4,5 @@
|
|||
: zeep 8777 debug ;
|
||||
: borg debug ;
|
||||
|
||||
\ 42 42 = debug if 69 . else 420 . then cr
|
||||
42 42 = debug if 69 . else 420 . then cr
|
||||
|
||||
0 if 42 . cr debug else 69 . cr then
|
||||
test debug meep morp zeep borg debug
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue