Update
This commit is contained in:
parent
fcc8379cc3
commit
7144eb4b24
3 changed files with 129 additions and 32 deletions
|
@ -3,8 +3,11 @@
|
||||||
.include "$lib/core.asm"
|
.include "$lib/core.asm"
|
||||||
.include "$lib/std.asm"
|
.include "$lib/std.asm"
|
||||||
|
|
||||||
|
.define PLACEHOLDER_U8, CORE_U8_MAX
|
||||||
|
.define PLACEHOLDER_U16, CORE_U16_MAX
|
||||||
|
|
||||||
.define_eval prev, OFFSET
|
.define_eval prev, OFFSET
|
||||||
ts CORE_U16_MAX
|
ts PLACEHOLDER_U16
|
||||||
tlr CORE_REG_PC
|
tlr CORE_REG_PC
|
||||||
.define_eval diff, (OFFSET - prev)
|
.define_eval diff, (OFFSET - prev)
|
||||||
.define_eval MAIN_JUMPER, (CORE_MEM_PRG_END - diff)
|
.define_eval MAIN_JUMPER, (CORE_MEM_PRG_END - diff)
|
||||||
|
@ -12,13 +15,13 @@
|
||||||
.delete prev, diff
|
.delete prev, diff
|
||||||
|
|
||||||
.define_eval prev, OFFSET
|
.define_eval prev, OFFSET
|
||||||
.bytes CORE_U16_MAX, CORE_U16_MAX
|
.bytes PLACEHOLDER_U16, PLACEHOLDER_U16
|
||||||
.bytes CORE_U16_MAX
|
.bytes PLACEHOLDER_U16
|
||||||
.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, (1 * 2)
|
.define_eval JUMP_TABLE_WORDS_SIZE, (3 * 2)
|
||||||
.define_eval JUMP_TABLE_PTR, (MAIN_JUMPER - JUMP_TABLE_CONDITIONS_SIZE - JUMP_TABLE_WORDS_SIZE)
|
.define_eval JUMP_TABLE_PTR, (MAIN_JUMPER - JUMP_TABLE_CONDITIONS_SIZE - JUMP_TABLE_WORDS_SIZE)
|
||||||
|
|
||||||
.debug JUMP_TABLE_CONDITIONS_SIZE, JUMP_TABLE_WORDS_SIZE, (JUMP_TABLE_CONDITIONS_SIZE + JUMP_TABLE_WORDS_SIZE / 2), JUMP_TABLE_PTR
|
.debug JUMP_TABLE_CONDITIONS_SIZE, JUMP_TABLE_WORDS_SIZE, (JUMP_TABLE_CONDITIONS_SIZE + JUMP_TABLE_WORDS_SIZE / 2), JUMP_TABLE_PTR
|
||||||
|
@ -32,6 +35,14 @@
|
||||||
.define_eval counter, (counter + 2)
|
.define_eval counter, (counter + 2)
|
||||||
.define_eval jump_table_conditions_if_1, (JUMP_TABLE_PTR + counter)
|
.define_eval jump_table_conditions_if_1, (JUMP_TABLE_PTR + counter)
|
||||||
.define_eval counter, (counter + 2)
|
.define_eval counter, (counter + 2)
|
||||||
|
|
||||||
|
; words
|
||||||
|
.define_eval jump_table_words_0, (JUMP_TABLE_PTR + counter)
|
||||||
|
.define_eval counter, (counter + 1)
|
||||||
|
.define_eval jump_table_words_1, (JUMP_TABLE_PTR + counter)
|
||||||
|
.define_eval counter, (counter + 1)
|
||||||
|
.define_eval jump_table_words_2, (JUMP_TABLE_PTR + counter)
|
||||||
|
.define_eval counter, (counter + 1)
|
||||||
.delete counter
|
.delete counter
|
||||||
|
|
||||||
.define_eval MEM_JUMP_TABLE_LEN, (JUMP_TABLE_CONDITIONS_SIZE + JUMP_TABLE_WORDS_SIZE / 2)
|
.define_eval MEM_JUMP_TABLE_LEN, (JUMP_TABLE_CONDITIONS_SIZE + JUMP_TABLE_WORDS_SIZE / 2)
|
||||||
|
@ -55,27 +66,50 @@
|
||||||
tlr CORE_REG_A
|
tlr CORE_REG_A
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
.macro jump_table_pull_ptr, jump_table_pull_ptr_arg_0_ptr
|
.macro jump_table_pull_ptr, jump_table_pull_ptr_arg_0_ptr, jump_table_pull_ptr_arg_1_counter
|
||||||
.std_get jump_table_pull_ptr_arg_0_ptr
|
ts jump_table_pull_ptr_arg_0_ptr
|
||||||
tls
|
tls
|
||||||
|
|
||||||
|
ts 8
|
||||||
|
tlr CORE_REG_B
|
||||||
|
.std_get jump_table_pull_ptr_arg_0_ptr
|
||||||
|
tlr CORE_REG_A
|
||||||
|
ts CORE_ALU_LSH
|
||||||
|
alu
|
||||||
|
tlr CORE_REG_A
|
||||||
|
|
||||||
.std_get (jump_table_pull_ptr_arg_0_ptr + 1)
|
.std_get (jump_table_pull_ptr_arg_0_ptr + 1)
|
||||||
|
tlr CORE_REG_B
|
||||||
|
ts CORE_ALU_OR
|
||||||
|
alu
|
||||||
|
tlr CORE_REG_A
|
||||||
|
|
||||||
tls
|
tls
|
||||||
dbg
|
dbg
|
||||||
pop
|
pop
|
||||||
pop
|
pop
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
.define_eval counter, 0
|
||||||
; setup jump table
|
; setup jump table
|
||||||
; conditions
|
; conditions
|
||||||
; condition 0
|
.jump_table_pull_ptr jump_table_conditions_if_0, counter
|
||||||
; if
|
.define_eval counter, (counter + 1)
|
||||||
.jump_table_pull_ptr jump_table_conditions_if_0
|
.jump_table_pull_ptr jump_table_conditions_else_0, counter
|
||||||
|
.define_eval counter, (counter + 1)
|
||||||
|
.jump_table_pull_ptr jump_table_conditions_if_1, counter
|
||||||
|
.define_eval counter, (counter + 1)
|
||||||
|
|
||||||
; else
|
; words
|
||||||
.jump_table_pull_ptr jump_table_conditions_else_0
|
.jump_table_pull_ptr jump_table_words_0, counter
|
||||||
; condition 1
|
.define_eval counter, (counter + 1)
|
||||||
; if
|
.jump_table_pull_ptr jump_table_words_1, counter
|
||||||
.jump_table_pull_ptr jump_table_conditions_if_1
|
.define_eval counter, (counter + 1)
|
||||||
|
.jump_table_pull_ptr jump_table_words_2, counter
|
||||||
|
.define_eval counter, (counter + 1)
|
||||||
|
.delete counter
|
||||||
|
|
||||||
|
.delete_macro jump_table_pull_ptr
|
||||||
|
|
||||||
.macro self_ref, self_ref_arg_0_ptr
|
.macro self_ref, self_ref_arg_0_ptr
|
||||||
.std_rset CORE_REG_A, self_ref_arg_0_ptr
|
.std_rset CORE_REG_A, self_ref_arg_0_ptr
|
||||||
|
@ -140,13 +174,13 @@ return_call_stack_jump:
|
||||||
.define_eval prev, OFFSET
|
.define_eval prev, OFFSET
|
||||||
.std_ld
|
.std_ld
|
||||||
tlr CORE_REG_A
|
tlr CORE_REG_A
|
||||||
.std_rset CORE_REG_C, CORE_U16_MAX
|
.std_rset CORE_REG_C, PLACEHOLDER_U16
|
||||||
.std_rset CORE_REG_D, CORE_U16_MAX
|
.std_rset CORE_REG_D, PLACEHOLDER_U16
|
||||||
ts call_stack_jump
|
ts call_stack_jump
|
||||||
tlrc CORE_REG_PC
|
tlrc CORE_REG_PC
|
||||||
|
|
||||||
.std_rset CORE_REG_C, CORE_U16_MAX
|
.std_rset CORE_REG_C, PLACEHOLDER_U16
|
||||||
.std_rset CORE_REG_D, CORE_U16_MAX
|
.std_rset CORE_REG_D, PLACEHOLDER_U16
|
||||||
ts call_stack_jump
|
ts call_stack_jump
|
||||||
tlr CORE_REG_PC
|
tlr CORE_REG_PC
|
||||||
.define_eval CALL_STACK_JUMP_COND_IF_ELSE_SIZE, (OFFSET - prev)
|
.define_eval CALL_STACK_JUMP_COND_IF_ELSE_SIZE, (OFFSET - prev)
|
||||||
|
@ -230,6 +264,16 @@ return_call_stack_jump:
|
||||||
tls
|
tls
|
||||||
.return_call_stack_jump
|
.return_call_stack_jump
|
||||||
|
|
||||||
|
words_1:
|
||||||
|
push 32
|
||||||
|
.return_call_stack_jump
|
||||||
|
|
||||||
|
words_2:
|
||||||
|
push 4875
|
||||||
|
push 8748
|
||||||
|
dbg
|
||||||
|
.return_call_stack_jump
|
||||||
|
|
||||||
|
|
||||||
; static jump table
|
; static jump table
|
||||||
.define_eval prev, OFFSET
|
.define_eval prev, OFFSET
|
||||||
|
@ -244,6 +288,17 @@ return_call_stack_jump:
|
||||||
.org jump_table_conditions_if_1
|
.org jump_table_conditions_if_1
|
||||||
.bytes conditions_if_1
|
.bytes conditions_if_1
|
||||||
|
|
||||||
|
|
||||||
|
; words
|
||||||
|
.org jump_table_words_0
|
||||||
|
.bytes words_0
|
||||||
|
|
||||||
|
.org jump_table_words_1
|
||||||
|
.bytes words_1
|
||||||
|
|
||||||
|
.org jump_table_words_2
|
||||||
|
.bytes words_2
|
||||||
|
|
||||||
.org prev
|
.org prev
|
||||||
.delete prev
|
.delete prev
|
||||||
|
|
||||||
|
@ -305,4 +360,8 @@ main:
|
||||||
.std_cond_jump loop_strings_0
|
.std_cond_jump loop_strings_0
|
||||||
.std_rset CORE_REG_A, '\n'
|
.std_rset CORE_REG_A, '\n'
|
||||||
.std_set CORE_MEM_CHR
|
.std_set CORE_MEM_CHR
|
||||||
|
.call_stack_jump words_2
|
||||||
|
.call_stack_jump words_1
|
||||||
|
.call_stack_jump words_2
|
||||||
|
.call_stack_jump words_1
|
||||||
.std_stop
|
.std_stop
|
||||||
|
|
|
@ -8,3 +8,4 @@
|
||||||
1 debug if 32 . cr else then
|
1 debug if 32 . cr else then
|
||||||
|
|
||||||
test debug test debug space ." Hello world!" cr space space ." Hello world!" cr
|
test debug test debug space ." Hello world!" cr space space ." Hello world!" cr
|
||||||
|
morp meep morp meep
|
||||||
|
|
|
@ -3,8 +3,11 @@
|
||||||
.include "$lib/core.asm"
|
.include "$lib/core.asm"
|
||||||
.include "$lib/std.asm"
|
.include "$lib/std.asm"
|
||||||
|
|
||||||
|
.define PLACEHOLDER_U8, CORE_U8_MAX
|
||||||
|
.define PLACEHOLDER_U16, CORE_U16_MAX
|
||||||
|
|
||||||
.define_eval prev, OFFSET
|
.define_eval prev, OFFSET
|
||||||
ts CORE_U16_MAX
|
ts PLACEHOLDER_U16
|
||||||
tlr CORE_REG_PC
|
tlr CORE_REG_PC
|
||||||
.define_eval diff, (OFFSET - prev)
|
.define_eval diff, (OFFSET - prev)
|
||||||
.define_eval MAIN_JUMPER, (CORE_MEM_PRG_END - diff)
|
.define_eval MAIN_JUMPER, (CORE_MEM_PRG_END - diff)
|
||||||
|
@ -13,7 +16,7 @@
|
||||||
|
|
||||||
.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 PLACEHOLDER_U16{% if !c.data.1.is_empty() %}, PLACEHOLDER_U16{% endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
.define_eval JUMP_TABLE_CONDITIONS_SIZE, (OFFSET - prev)
|
.define_eval JUMP_TABLE_CONDITIONS_SIZE, (OFFSET - prev)
|
||||||
.org prev
|
.org prev
|
||||||
|
@ -35,6 +38,12 @@
|
||||||
.define_eval counter, (counter + 2)
|
.define_eval counter, (counter + 2)
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
|
; words
|
||||||
|
{%- for w in words %}
|
||||||
|
.define_eval jump_table_words_{{ w.id }}, (JUMP_TABLE_PTR + counter)
|
||||||
|
.define_eval counter, (counter + 1)
|
||||||
|
{%- endfor %}
|
||||||
.delete counter
|
.delete counter
|
||||||
|
|
||||||
.define_eval MEM_JUMP_TABLE_LEN, (JUMP_TABLE_CONDITIONS_SIZE + JUMP_TABLE_WORDS_SIZE / 2)
|
.define_eval MEM_JUMP_TABLE_LEN, (JUMP_TABLE_CONDITIONS_SIZE + JUMP_TABLE_WORDS_SIZE / 2)
|
||||||
|
@ -58,29 +67,51 @@
|
||||||
tlr CORE_REG_A
|
tlr CORE_REG_A
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
.macro jump_table_pull_ptr, jump_table_pull_ptr_arg_0_ptr
|
.macro jump_table_pull_ptr, jump_table_pull_ptr_arg_0_ptr, jump_table_pull_ptr_arg_1_counter
|
||||||
.std_get jump_table_pull_ptr_arg_0_ptr
|
ts jump_table_pull_ptr_arg_0_ptr
|
||||||
tls
|
tls
|
||||||
|
|
||||||
|
ts 8
|
||||||
|
tlr CORE_REG_B
|
||||||
|
.std_get jump_table_pull_ptr_arg_0_ptr
|
||||||
|
tlr CORE_REG_A
|
||||||
|
ts CORE_ALU_LSH
|
||||||
|
alu
|
||||||
|
tlr CORE_REG_A
|
||||||
|
|
||||||
.std_get (jump_table_pull_ptr_arg_0_ptr + 1)
|
.std_get (jump_table_pull_ptr_arg_0_ptr + 1)
|
||||||
|
tlr CORE_REG_B
|
||||||
|
ts CORE_ALU_OR
|
||||||
|
alu
|
||||||
|
tlr CORE_REG_A
|
||||||
|
|
||||||
tls
|
tls
|
||||||
dbg
|
dbg
|
||||||
pop
|
pop
|
||||||
pop
|
pop
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
.define_eval counter, 0
|
||||||
; setup jump table
|
; setup jump table
|
||||||
; conditions
|
; conditions
|
||||||
{%- for c in conditions %}
|
{%- for c in conditions %}
|
||||||
; condition {{ c.id }}
|
.jump_table_pull_ptr jump_table_conditions_if_{{ c.id }}, counter
|
||||||
; if
|
.define_eval counter, (counter + 1)
|
||||||
.jump_table_pull_ptr jump_table_conditions_if_{{ c.id }}
|
|
||||||
{%- if !c.data.1.is_empty() %}
|
{%- if !c.data.1.is_empty() %}
|
||||||
|
.jump_table_pull_ptr jump_table_conditions_else_{{ c.id }}, counter
|
||||||
; else
|
.define_eval counter, (counter + 1)
|
||||||
.jump_table_pull_ptr jump_table_conditions_else_{{ c.id }}
|
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
|
; words
|
||||||
|
{%- for w in words %}
|
||||||
|
.jump_table_pull_ptr jump_table_words_{{ w.id }}, counter
|
||||||
|
.define_eval counter, (counter + 1)
|
||||||
|
{%- endfor %}
|
||||||
|
.delete counter
|
||||||
|
|
||||||
|
.delete_macro jump_table_pull_ptr
|
||||||
|
|
||||||
.macro self_ref, self_ref_arg_0_ptr
|
.macro self_ref, self_ref_arg_0_ptr
|
||||||
.std_rset CORE_REG_A, self_ref_arg_0_ptr
|
.std_rset CORE_REG_A, self_ref_arg_0_ptr
|
||||||
.std_set self_ref_arg_0_ptr
|
.std_set self_ref_arg_0_ptr
|
||||||
|
@ -144,13 +175,13 @@ return_call_stack_jump:
|
||||||
.define_eval prev, OFFSET
|
.define_eval prev, OFFSET
|
||||||
.std_ld
|
.std_ld
|
||||||
tlr CORE_REG_A
|
tlr CORE_REG_A
|
||||||
.std_rset CORE_REG_C, CORE_U16_MAX
|
.std_rset CORE_REG_C, PLACEHOLDER_U16
|
||||||
.std_rset CORE_REG_D, CORE_U16_MAX
|
.std_rset CORE_REG_D, PLACEHOLDER_U16
|
||||||
ts call_stack_jump
|
ts call_stack_jump
|
||||||
tlrc CORE_REG_PC
|
tlrc CORE_REG_PC
|
||||||
|
|
||||||
.std_rset CORE_REG_C, CORE_U16_MAX
|
.std_rset CORE_REG_C, PLACEHOLDER_U16
|
||||||
.std_rset CORE_REG_D, CORE_U16_MAX
|
.std_rset CORE_REG_D, PLACEHOLDER_U16
|
||||||
ts call_stack_jump
|
ts call_stack_jump
|
||||||
tlr CORE_REG_PC
|
tlr CORE_REG_PC
|
||||||
.define_eval CALL_STACK_JUMP_COND_IF_ELSE_SIZE, (OFFSET - prev)
|
.define_eval CALL_STACK_JUMP_COND_IF_ELSE_SIZE, (OFFSET - prev)
|
||||||
|
@ -230,6 +261,12 @@ return_call_stack_jump:
|
||||||
.bytes conditions_else_{{ c.id }}
|
.bytes conditions_else_{{ c.id }}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
; words
|
||||||
|
{%- for w in words %}
|
||||||
|
.org jump_table_words_{{ w.id }}
|
||||||
|
.bytes words_{{ w.id }}
|
||||||
|
{% endfor %}
|
||||||
.org prev
|
.org prev
|
||||||
.delete prev
|
.delete prev
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue