diff options
Diffstat (limited to 'atk16_asm/builtin_asm')
| -rw-r--r-- | atk16_asm/builtin_asm/std_term.atk16 | 46 |
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 |
