Update WIP with jump table for words and conditions
This commit is contained in:
parent
df73353bc6
commit
00bab636db
10 changed files with 234 additions and 116 deletions
|
@ -1,16 +1,29 @@
|
|||
; Generated by Henceforth 0.1.0 (https://git.dergrimm.net/dergrimm/hence.git)
|
||||
|
||||
.include "$lib/core.asm"
|
||||
.include "$lib/std.asm"
|
||||
;.include "$lib/main.asm"
|
||||
|
||||
.define_eval prev, OFFSET
|
||||
ts 0xffff
|
||||
ts CORE_U16_MAX
|
||||
tlr CORE_REG_PC
|
||||
.define_eval diff, (OFFSET - prev)
|
||||
.define_eval MAIN_JUMPER, (CORE_MEM_PRG_END - diff)
|
||||
.org prev
|
||||
.delete prev, diff
|
||||
|
||||
.define_eval MAIN_JUMPER, (CORE_MEM_PRG_END - 3 - 1)
|
||||
.define_eval prev, OFFSET
|
||||
.bytes NULL
|
||||
.bytes NULL
|
||||
|
||||
.define_eval INDEX_CONDITIONS_SIZE, (OFFSET - prev)
|
||||
.org prev
|
||||
.delete prev
|
||||
|
||||
.debug INDEX_CONDITIONS_SIZE
|
||||
|
||||
; index
|
||||
index_conditions_if_0:
|
||||
|
||||
|
||||
.define_eval MEM_LOOP_DEPTH, CORE_MEM_MEM
|
||||
.define_eval MEM_LOOP_I, (MEM_LOOP_DEPTH + 1)
|
||||
|
@ -66,39 +79,85 @@ return_call_stack_jump:
|
|||
get
|
||||
tlr CORE_REG_PC
|
||||
|
||||
.macro call_stack_jump, call_stack_jump_arg_0_label, call_stack_jump_arg_1_offset
|
||||
.std_rset CORE_REG_C, call_stack_jump_arg_0_label
|
||||
.std_rset CORE_REG_D, (call_stack_jump_arg_1_offset + 7)
|
||||
.define_eval prev, OFFSET
|
||||
.std_rset CORE_REG_C, CORE_U16_MAX
|
||||
.std_rset CORE_REG_D, CORE_U16_MAX
|
||||
ts call_stack_jump
|
||||
tlr CORE_REG_PC
|
||||
.define_eval CALL_STACK_JUMP_SIZE, (OFFSET - prev)
|
||||
.org prev
|
||||
.delete prev
|
||||
|
||||
.macro call_stack_jump, call_stack_jump_arg_0_label
|
||||
.define_eval prev, OFFSET
|
||||
.define offset_till_end, (OFFSET - prev * -1 + CALL_STACK_JUMP_COND_IF_ELSE_SIZE)
|
||||
|
||||
.std_rset CORE_REG_C, call_stack_jump_arg_0_label
|
||||
.std_rset CORE_REG_D, (OFFSET + offset_till_end)
|
||||
ts call_stack_jump
|
||||
tlr CORE_REG_PC
|
||||
|
||||
.delete prev, offset_till_end
|
||||
.endmacro
|
||||
|
||||
.macro call_stack_jump_cond_if, call_stack_jump_cond_if_arg_0_if_label, call_stack_jump_cond_if_arg_1_offset
|
||||
.define_eval prev, OFFSET
|
||||
.std_ld
|
||||
tlr CORE_REG_A
|
||||
.std_rset CORE_REG_C, CORE_U16_MAX
|
||||
.std_rset CORE_REG_D, CORE_U16_MAX
|
||||
ts call_stack_jump
|
||||
tlrc CORE_REG_PC
|
||||
.define_eval CALL_STACK_JUMP_COND_IF_SIZE, (OFFSET - prev)
|
||||
.org prev
|
||||
.delete prev
|
||||
|
||||
.macro call_stack_jump_cond_if, call_stack_jump_cond_if_arg_0_if_label
|
||||
.define_eval prev, OFFSET
|
||||
.define offset_till_end, (OFFSET - prev * -1 + CALL_STACK_JUMP_COND_IF_ELSE_SIZE)
|
||||
|
||||
.std_ld
|
||||
tlr CORE_REG_A
|
||||
.std_rset CORE_REG_C, call_stack_jump_cond_if_arg_0_if_label
|
||||
.std_rset CORE_REG_D, (call_stack_jump_cond_if_arg_1_offset + 7)
|
||||
.std_rset CORE_REG_D, (OFFSET + offset_till_end)
|
||||
ts call_stack_jump
|
||||
tlrc CORE_REG_PC
|
||||
|
||||
.delete prev, offset_till_end
|
||||
.endmacro
|
||||
|
||||
.macro call_stack_jump_cond_if_else, call_stack_jump_cond_if_else_arg_0_if_label, call_stack_jump_cond_if_else_arg_1_else_label, call_stack_jump_cond_if_else_arg_2_offset
|
||||
.define_eval prev, OFFSET
|
||||
.std_ld
|
||||
tlr CORE_REG_A
|
||||
.std_rset CORE_REG_C, CORE_U16_MAX
|
||||
.std_rset CORE_REG_D, CORE_U16_MAX
|
||||
ts call_stack_jump
|
||||
tlrc CORE_REG_PC
|
||||
|
||||
.std_rset CORE_REG_C, CORE_U16_MAX
|
||||
.std_rset CORE_REG_D, CORE_U16_MAX
|
||||
ts call_stack_jump
|
||||
tlr CORE_REG_PC
|
||||
.define_eval CALL_STACK_JUMP_COND_IF_ELSE_SIZE, (OFFSET - prev)
|
||||
.org prev
|
||||
.delete prev
|
||||
|
||||
.macro call_stack_jump_cond_if_else, call_stack_jump_cond_if_else_arg_0_if_label, call_stack_jump_cond_if_else_arg_1_else_label
|
||||
.define_eval prev, OFFSET
|
||||
.define offset_till_end, (OFFSET - prev * -1 + CALL_STACK_JUMP_COND_IF_ELSE_SIZE)
|
||||
|
||||
.std_ld
|
||||
tlr CORE_REG_A
|
||||
.std_rset CORE_REG_C, call_stack_jump_cond_if_else_arg_0_if_label
|
||||
.define_eval call_stack_jump_cond_if_else_local_end_offset, (call_stack_jump_cond_if_else_arg_2_offset + 11)
|
||||
.debug call_stack_jump_cond_if_else_local_end_offset
|
||||
.std_rset CORE_REG_D, call_stack_jump_cond_if_else_local_end_offset
|
||||
.std_rset CORE_REG_D, (OFFSET + offset_till_end)
|
||||
ts call_stack_jump
|
||||
tlrc CORE_REG_PC
|
||||
|
||||
.std_rset CORE_REG_C, call_stack_jump_cond_if_else_arg_1_else_label
|
||||
.std_rset CORE_REG_D, (call_stack_jump_cond_if_else_arg_2_offset + 11)
|
||||
.std_rset CORE_REG_D, (OFFSET + offset_till_end)
|
||||
ts call_stack_jump
|
||||
tlr CORE_REG_PC
|
||||
.debug call_stack_jump_cond_if_else_local_end_offset
|
||||
|
||||
.delete call_stack_jump_cond_if_else_local_end_offset
|
||||
.delete prev, offset_till_end
|
||||
.endmacro
|
||||
|
||||
.macro return_call_stack_jump
|
||||
|
@ -117,10 +176,16 @@ 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
|
||||
|
||||
conditions_else_0:
|
||||
push 42
|
||||
push 69
|
||||
.std_ld
|
||||
tlr CORE_REG_A
|
||||
.std_set CORE_MEM_OUT
|
||||
|
@ -139,6 +204,29 @@ return_call_stack_jump:
|
|||
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:
|
||||
|
@ -148,9 +236,12 @@ main:
|
|||
|
||||
.org main
|
||||
push 0
|
||||
.call_stack_jump_cond_if_else conditions_if_0, conditions_else_0, OFFSET
|
||||
.call_stack_jump words_0, OFFSET
|
||||
.call_stack_jump_cond_if_else conditions_if_0, conditions_else_0
|
||||
.call_stack_jump words_0
|
||||
dbg
|
||||
.call_stack_jump words_0, OFFSET
|
||||
.call_stack_jump words_1
|
||||
.call_stack_jump words_2
|
||||
.call_stack_jump words_3
|
||||
.call_stack_jump words_4
|
||||
dbg
|
||||
.std_stop
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
: test 40 2 + ;
|
||||
: meep 32 ;
|
||||
: morp 4875 8748 debug ;
|
||||
: zeep 8777 debug ;
|
||||
: borg debug ;
|
||||
|
||||
\ 42 42 = debug if 69 . else 420 . then cr
|
||||
|
||||
0 if 42 . cr else 69 . cr then
|
||||
test debug test debug
|
||||
0 if 42 . cr test meep morp zeep borg debug else 69 . cr then
|
||||
test debug meep morp zeep borg debug
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue