Did stuff again

This commit is contained in:
Dominic Grimm 2022-08-26 15:02:48 +02:00
parent 8d15e300b7
commit 6f28879402
14 changed files with 74 additions and 151 deletions

View file

@ -61,65 +61,8 @@ forth:
ts jump_main
tlr CORE_REG_PC
end_input:
dbg
main:
; loop body
loop:
; read key from stdin
ts CORE_MEM_KEY
get
; check if key is newline (0x0a)
tlr CORE_REG_D ; store in register D because register A is used later on
tlr CORE_REG_A ; store in register A as input for ALU
ts "\n" ; store newline in TMP
tlr CORE_REG_B ; store newline in register B as input for ALU
ts CORE_ALU_EQ ; ALU equal operation
alu ; run ALU
; go back to loop start if pressed key is newline
tlr CORE_REG_A ; store result of ALU operation in TMP
; ts loop ; load memory address of loop start into TMP
ts 0
tls
ts jump_switch
tls
ts end_input
tlrc CORE_REG_PC ; set register PC to loop start address if result is true
pop
tlr CORE_REG_A
ts 0
tlrc CORE_REG_C
; print out char
tsr CORE_REG_D ; get char
tlr CORE_REG_A ; load char into register A
ts CORE_MEM_CHR ; set TMP to char print memory address
set ; print char
; increment counter by one
tsr CORE_REG_C
tlr CORE_REG_A
ts 1
tlr CORE_REG_B
ts CORE_ALU_ADD
alu
tlr CORE_REG_C
tlr CORE_REG_A
ts FORTH_MEM_INPUT_SIZE
tlr CORE_REG_B
ts CORE_ALU_LT
alu
tlr CORE_REG_A
ts loop
tlrc CORE_REG_PC
ts "\n"
tlr CORE_REG_A
dbg
; set PC to maximum for u16 and therefore stops program execution
ts 0xffff ; load 0xffff into TMP
@ -128,3 +71,4 @@ tlr CORE_REG_PC ; store value of TMP into register PC
.org jump_main
ts main
tlr CORE_REG_PC

Binary file not shown.