Add working macro system
This commit is contained in:
parent
6adb943754
commit
1ff9a6c44b
19 changed files with 1258 additions and 571 deletions
6
forth/constants.asm
Normal file
6
forth/constants.asm
Normal file
|
@ -0,0 +1,6 @@
|
|||
.requires "$lib/core.asm"
|
||||
|
||||
.define MEM_INPUT_SIZE, 16
|
||||
.define MEM_INPUT_DYN_END, CORE_MEM_MEM
|
||||
.define MEM_INPUT_START, (MEM_INPUT_DYN_END + 1)
|
||||
.define MEM_INPUT_END, (MEM_INPUT_START + MEM_INPUT_SIZE)
|
64
forth/main.asm
Normal file
64
forth/main.asm
Normal file
|
@ -0,0 +1,64 @@
|
|||
.include "$lib/core.asm"
|
||||
.include "$lib/std.asm"
|
||||
.include "$lib/main.asm"
|
||||
|
||||
.include "constants.asm"
|
||||
|
||||
.jump_main
|
||||
|
||||
data:
|
||||
|
||||
.main
|
||||
.std_rset CORE_REG_C, MEM_INPUT_START
|
||||
get_input_loop:
|
||||
.std_get CORE_MEM_KEY
|
||||
tlr CORE_REG_A
|
||||
@ tlr CORE_REG_D
|
||||
.std_set CORE_MEM_CHR
|
||||
tsr CORE_REG_C
|
||||
set
|
||||
|
||||
@ .std_rset CORE_REG_B, ' '
|
||||
@ .std_alu CORE_ALU_EQ
|
||||
@ tlr CORE_REG_A
|
||||
@ .std_cond_jump get_input_loop
|
||||
@ .std_cp CORE_REG_D, CORE_REG_A
|
||||
|
||||
tlr CORE_REG_A
|
||||
.std_rset CORE_REG_B, 1
|
||||
.std_alu CORE_ALU_ADD
|
||||
tlr CORE_REG_A
|
||||
tlr CORE_REG_C
|
||||
|
||||
.std_rset CORE_REG_B, MEM_INPUT_END
|
||||
.std_alu CORE_ALU_LT
|
||||
tlr CORE_REG_A
|
||||
.std_cond_jump get_input_loop
|
||||
|
||||
.std_cp CORE_REG_C, CORE_REG_A
|
||||
.std_set MEM_INPUT_DYN_END
|
||||
|
||||
.std_rset CORE_REG_A, '\n'
|
||||
.std_set CORE_MEM_CHR
|
||||
|
||||
.std_rset CORE_REG_B, MEM_INPUT_START
|
||||
.std_get MEM_INPUT_DYN_END
|
||||
tlr CORE_REG_D
|
||||
print_loop:
|
||||
tsr CORE_REG_B
|
||||
get
|
||||
tlr CORE_REG_A
|
||||
.std_set CORE_MEM_CHR
|
||||
|
||||
.std_rset CORE_REG_A, 1
|
||||
.std_alu CORE_ALU_ADD
|
||||
tlr CORE_REG_B
|
||||
|
||||
.std_cp CORE_REG_D, CORE_REG_A
|
||||
.std_alu CORE_ALU_GT
|
||||
tlr CORE_REG_A
|
||||
.std_cond_jump print_loop
|
||||
|
||||
.std_rset CORE_REG_A, '\n'
|
||||
.std_set CORE_MEM_CHR
|
||||
.std_stop
|
Loading…
Add table
Add a link
Reference in a new issue