hence/examples/henceforth.asm

56 lines
1.1 KiB
NASM

.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