aboutsummaryrefslogtreecommitdiffstats
path: root/atk16_asm/builtin_asm
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2024-04-15 23:16:41 +0300
committerJan Tuomi <jan@jantuomi.fi>2024-04-15 23:16:41 +0300
commit3589b9be557fddc859405b937c3ed84342d66852 (patch)
tree3b3605b00fd6baf5057862714742a095bb26d46e /atk16_asm/builtin_asm
parentf40d601771b9656a873c57dbf2527a5ec8600bd0 (diff)
Work on monitor, add std_term
Diffstat (limited to 'atk16_asm/builtin_asm')
-rw-r--r--atk16_asm/builtin_asm/std_term.atk1646
1 files changed, 46 insertions, 0 deletions
diff --git a/atk16_asm/builtin_asm/std_term.atk16 b/atk16_asm/builtin_asm/std_term.atk16
new file mode 100644
index 0000000..b0c9f4f
--- /dev/null
+++ b/atk16_asm/builtin_asm/std_term.atk16
@@ -0,0 +1,46 @@
+@label log_term_char
+ ; send a character to the terminal
+ ; parameters: RA = character code
+ ; return: none
+
+ ; RG is allowed to be clobbered by the calling convention
+ ldi vt_term_pp_addr RG ; RG := terminal address pointer
+ ldr RG RG ; RG := terminal address
+
+ str RA RG ; write 'A' to terminal
+ return
+
+
+
+@label log_term_string
+ ; send a string to the terminal
+ ; parameters: RA = address of string allocation
+ ; return: none
+
+ ; strings are encoded as a length word followed by the string data
+ ; RG is allowed to be clobbered by the calling convention
+ ldi vt_term_pp_addr RG ; RG := terminal address pointer
+ ldr RG RG ; RG := terminal address
+
+ stack_stash RA RB RC RD
+
+ ldr RA RB ; RB := string length
+ ldi 0 RC ; RC := 0
+
+@label log_term_string_loop
+ sub RB RC RD ; RD := remaining length
+ bri zero log_term_string_done
+
+ add RC RA RD ; RD := pointer to next character - 1
+ addi RD 1 RD ; RD := pointer to next character
+
+ ldr RD RD ; RD := next character
+
+ str RD RG ; write character to terminal
+ inc RC ; increment pointer
+
+ jpi log_term_string_loop
+
+@label log_term_string_done
+ stack_restore RA RB RC RD
+ return