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
|
.org prev
|
||||||
.delete prev, diff
|
.delete prev, diff
|
||||||
|
|
||||||
; .define_eval prev, OFFSET
|
.define_eval prev, OFFSET
|
||||||
;
|
.bytes CORE_U16_MAX, CORE_U16_MAX
|
||||||
; .bytes CORE_U16_MAX, CORE_U16_MAX
|
.define_eval JUMP_TABLE_CONDITIONS_SIZE, (OFFSET - prev)
|
||||||
;
|
.org prev
|
||||||
; .define_eval JUMP_TABLE_CONDITIONS_SIZE, (OFFSET - prev)
|
.delete 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)
|
.debug JUMP_TABLE_CONDITIONS_SIZE, JUMP_TABLE_WORDS_SIZE, (JUMP_TABLE_CONDITIONS_SIZE + JUMP_TABLE_WORDS_SIZE / 2), JUMP_TABLE_PTR
|
||||||
; .define_eval MEM_JUMP_TABLE_PTR, CORE_MEM_MEM
|
|
||||||
; .define_eval MEM_JUMP_TABLE_END, (MEM_JUMP_TABLE_PTR + MEM_JUMP_TABLE_LEN)
|
|
||||||
|
|
||||||
; .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
|
.define_eval MEM_JUMP_TABLE_LEN, (JUMP_TABLE_CONDITIONS_SIZE + JUMP_TABLE_WORDS_SIZE / 2)
|
||||||
; ; 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_PTR, CORE_MEM_MEM
|
.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_JUMP_TABLE_END, (MEM_JUMP_TABLE_PTR + MEM_JUMP_TABLE_LEN)
|
||||||
|
|
||||||
|
@ -58,7 +53,14 @@
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
; setup jump table
|
; 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
|
; reference MEM_CALL_STACK_PTR to itself
|
||||||
.std_rset CORE_REG_A, MEM_CALL_STACK_PTR
|
.std_rset CORE_REG_A, MEM_CALL_STACK_PTR
|
||||||
|
@ -190,22 +192,17 @@ return_call_stack_jump:
|
||||||
; conditions
|
; conditions
|
||||||
; condition: 0
|
; condition: 0
|
||||||
conditions_if_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
|
push 69
|
||||||
.std_ld
|
.std_ld
|
||||||
tlr CORE_REG_A
|
tlr CORE_REG_A
|
||||||
.std_set CORE_MEM_OUT
|
.std_set CORE_MEM_OUT
|
||||||
.std_rset CORE_REG_A, '\n'
|
.return_call_stack_jump
|
||||||
.std_set CORE_MEM_CHR
|
|
||||||
|
conditions_else_0:
|
||||||
|
push 420
|
||||||
|
.std_ld
|
||||||
|
tlr CORE_REG_A
|
||||||
|
.std_set CORE_MEM_OUT
|
||||||
.return_call_stack_jump
|
.return_call_stack_jump
|
||||||
|
|
||||||
|
|
||||||
|
@ -218,20 +215,13 @@ main:
|
||||||
tlr CORE_REG_PC
|
tlr CORE_REG_PC
|
||||||
|
|
||||||
.org main
|
.org main
|
||||||
push 0
|
push 42
|
||||||
.call_stack_jump_cond_if_else conditions_if_0, conditions_else_0
|
tls
|
||||||
push 40
|
|
||||||
push 2
|
|
||||||
.stack_transfer_alu
|
.stack_transfer_alu
|
||||||
.std_alu CORE_ALU_ADD
|
.std_alu CORE_ALU_EQ
|
||||||
tls
|
tls
|
||||||
dbg
|
dbg
|
||||||
push 32
|
.call_stack_jump_cond_if_else conditions_if_0, conditions_else_0
|
||||||
push 4875
|
.std_rset CORE_REG_A, '\n'
|
||||||
push 8748
|
.std_set CORE_MEM_CHR
|
||||||
dbg
|
|
||||||
push 8777
|
|
||||||
dbg
|
|
||||||
dbg
|
|
||||||
dbg
|
|
||||||
.std_stop
|
.std_stop
|
||||||
|
|
|
@ -4,7 +4,5 @@
|
||||||
: zeep 8777 debug ;
|
: zeep 8777 debug ;
|
||||||
: borg 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
|
.org prev
|
||||||
.delete prev, diff
|
.delete prev, diff
|
||||||
|
|
||||||
; .define_eval prev, OFFSET
|
.define_eval prev, OFFSET
|
||||||
; {%- for c in conditions %}
|
{%- for c in conditions %}
|
||||||
; .bytes CORE_U16_MAX{% if !c.data.1.is_empty() %}, CORE_U16_MAX{% endif %}
|
.bytes CORE_U16_MAX{% if !c.data.1.is_empty() %}, CORE_U16_MAX{% endif %}
|
||||||
; {%- endfor %}
|
{%- endfor %}
|
||||||
; .define_eval JUMP_TABLE_CONDITIONS_SIZE, (OFFSET - prev)
|
.define_eval JUMP_TABLE_CONDITIONS_SIZE, (OFFSET - prev)
|
||||||
; .org prev
|
.org prev
|
||||||
; .delete 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)
|
.debug JUMP_TABLE_CONDITIONS_SIZE, JUMP_TABLE_WORDS_SIZE, (JUMP_TABLE_CONDITIONS_SIZE + JUMP_TABLE_WORDS_SIZE / 2), JUMP_TABLE_PTR
|
||||||
; .define_eval MEM_JUMP_TABLE_PTR, CORE_MEM_MEM
|
|
||||||
; .define_eval MEM_JUMP_TABLE_END, (MEM_JUMP_TABLE_PTR + MEM_JUMP_TABLE_LEN)
|
|
||||||
|
|
||||||
; .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
|
.define_eval MEM_JUMP_TABLE_LEN, (JUMP_TABLE_CONDITIONS_SIZE + JUMP_TABLE_WORDS_SIZE / 2)
|
||||||
; ; 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_PTR, CORE_MEM_MEM
|
||||||
.define_eval MEM_JUMP_TABLE_END, (MEM_JUMP_TABLE_PTR + MEM_JUMP_TABLE_LEN)
|
.define_eval MEM_JUMP_TABLE_END, (MEM_JUMP_TABLE_PTR + MEM_JUMP_TABLE_LEN)
|
||||||
|
|
||||||
|
@ -62,7 +63,17 @@
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
; setup jump table
|
; 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
|
; reference MEM_CALL_STACK_PTR to itself
|
||||||
.std_rset CORE_REG_A, MEM_CALL_STACK_PTR
|
.std_rset CORE_REG_A, MEM_CALL_STACK_PTR
|
||||||
|
@ -229,6 +240,12 @@ return_call_stack_jump:
|
||||||
.return_call_stack_jump
|
.return_call_stack_jump
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
.define_eval prev, OFFSET
|
||||||
|
.org JUMP_TABLE_PTR
|
||||||
|
|
||||||
|
.org prev
|
||||||
|
.delete prev
|
||||||
|
|
||||||
; main
|
; main
|
||||||
main:
|
main:
|
||||||
.org MAIN_JUMPER
|
.org MAIN_JUMPER
|
||||||
|
|
Loading…
Reference in a new issue