Update after a long time!
This commit is contained in:
parent
2bc7ee5f42
commit
d6f7a51e11
32 changed files with 3005 additions and 117 deletions
56
examples/henceforth.asm
Normal file
56
examples/henceforth.asm
Normal file
|
@ -0,0 +1,56 @@
|
|||
.include "$lib/core.asm"
|
||||
.include "$lib/std.asm"
|
||||
.include "$lib/main.asm"
|
||||
|
||||
.define HENCEFORTH_SOURCE_MAX_LEN, 128
|
||||
.define HENCEFORTH_SOURCE_START, CORE_MEM_MEM
|
||||
.define HENCEFORTH_SOURCE_END, (HENCEFORTH_SOURCE_START + HENCEFORTH_SOURCE_MAX_LEN)
|
||||
.define HENCEFORTH_SOURCE_LEN, (HENCEFORTH_SOURCE_END + 1)
|
||||
|
||||
.jump_main
|
||||
|
||||
.def_main
|
||||
ts HENCEFORTH_SOURCE_START
|
||||
tlr CORE_REG_B
|
||||
|
||||
loop:
|
||||
; get key press
|
||||
ts CORE_MEM_KEY
|
||||
get
|
||||
tlr CORE_REG_A
|
||||
|
||||
; echo
|
||||
ts CORE_MEM_CHR
|
||||
set
|
||||
|
||||
; store in source
|
||||
tsr CORE_REG_B
|
||||
set
|
||||
|
||||
; increment pointer
|
||||
ts 1
|
||||
tlr CORE_REG_A
|
||||
ts CORE_ALU_ADD
|
||||
alu
|
||||
tlr CORE_REG_B
|
||||
|
||||
; jump to loop start or not
|
||||
; backup
|
||||
tsr CORE_REG_B
|
||||
tlr CORE_REG_C
|
||||
|
||||
; check
|
||||
ts HENCEFORTH_SOURCE_END
|
||||
tlr CORE_REG_A
|
||||
ts CORE_ALU_GT
|
||||
alu
|
||||
tlr CORE_REG_A
|
||||
|
||||
; restore
|
||||
tsr CORE_REG_C
|
||||
tlr CORE_REG_B
|
||||
|
||||
; jump
|
||||
ts loop
|
||||
tlrc CORE_REG_PC
|
||||
.std_stop
|
|
@ -5,5 +5,4 @@
|
|||
.jump_main
|
||||
|
||||
main: .main main
|
||||
|
||||
.std_stop
|
||||
|
|
Binary file not shown.
68
examples/testforth.asm
Normal file
68
examples/testforth.asm
Normal file
|
@ -0,0 +1,68 @@
|
|||
.include "$lib/core.asm"
|
||||
.include "$lib/std.asm"
|
||||
.include "$lib/main.asm"
|
||||
.define MEM_LOOP_I, CORE_MEM_MEM
|
||||
.define MEM_LOOP_J, (MEM_LOOP_I + 1)
|
||||
.define MEM_CALL_STACK_LEN, 16
|
||||
.define MEM_CALL_STACK_PTR, (MEM_LOOP_J + 1)
|
||||
.define MEM_CALL_STACK_END, (MEM_CALL_STACK_PTR + MEM_CALL_STACK_LEN)
|
||||
.define MEM_ALLOC_PTR, MEM_CALL_STACK_END
|
||||
.macro stack_transfer_alu
|
||||
.std_ld
|
||||
tlr CORE_REG_B
|
||||
.std_ld
|
||||
tlr CORE_REG_A
|
||||
.endmacro
|
||||
.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)
|
||||
ts call_stack_jump
|
||||
tlr CORE_REG_PC
|
||||
.endmacro
|
||||
.macro return_call_stack_jump
|
||||
.std_jump return_call_stack_jump
|
||||
.endmacro
|
||||
.std_rset CORE_REG_A, MEM_CALL_STACK_PTR
|
||||
.std_set MEM_CALL_STACK_PTR
|
||||
.std_rset CORE_REG_A, (MEM_ALLOC_PTR + 1)
|
||||
.std_set MEM_ALLOC_PTR
|
||||
.jump_main
|
||||
call_stack_jump:
|
||||
.std_get MEM_CALL_STACK_PTR
|
||||
tlr CORE_REG_A
|
||||
.std_rset CORE_REG_B, 1
|
||||
.std_alu CORE_ALU_ADD
|
||||
tlr CORE_REG_A
|
||||
tlr CORE_REG_B
|
||||
.std_set MEM_CALL_STACK_PTR
|
||||
tsr CORE_REG_D
|
||||
tlr CORE_REG_A
|
||||
tsr CORE_REG_B
|
||||
set
|
||||
tsr CORE_REG_C
|
||||
tlr CORE_REG_PC
|
||||
return_call_stack_jump:
|
||||
.std_get MEM_CALL_STACK_PTR
|
||||
tlr CORE_REG_A
|
||||
tlr CORE_REG_C
|
||||
.std_rset CORE_REG_B, 1
|
||||
.std_alu CORE_ALU_SUB
|
||||
tlr CORE_REG_A
|
||||
.std_set MEM_CALL_STACK_PTR
|
||||
tsr CORE_REG_C
|
||||
get
|
||||
tlr CORE_REG_PC
|
||||
words_0:
|
||||
; word: "test"
|
||||
push 40
|
||||
push 2
|
||||
.stack_transfer_alu
|
||||
.std_alu CORE_ALU_ADD
|
||||
tls
|
||||
.return_call_stack_jump
|
||||
main:
|
||||
.main main
|
||||
.call_stack_jump words_0, OFFSET
|
||||
dbg
|
||||
.call_stack_jump words_0, OFFSET
|
||||
.std_stop
|
3
examples/testforth.fth
Normal file
3
examples/testforth.fth
Normal file
|
@ -0,0 +1,3 @@
|
|||
: test 40 2 + ;
|
||||
|
||||
test debug test
|
Loading…
Add table
Add a link
Reference in a new issue