summaryrefslogtreecommitdiff
path: root/boot/common-boot.s
diff options
context:
space:
mode:
Diffstat (limited to 'boot/common-boot.s')
-rw-r--r--boot/common-boot.s26
1 files changed, 25 insertions, 1 deletions
diff --git a/boot/common-boot.s b/boot/common-boot.s
index 9c5ebc4..c6fcb98 100644
--- a/boot/common-boot.s
+++ b/boot/common-boot.s
@@ -1,4 +1,5 @@
-.global _is_alpha, _is_digit, _is_alnum, _is_upper, _is_lower, _write_out, _read_file, exit, _memcmp, _write_error
+.global _is_alpha, _is_digit, _is_alnum, _is_upper, _is_lower
+.global _write_out, _read_file, exit, _memcmp, _write_error, _put_char
.section .rodata
@@ -200,6 +201,29 @@ _read_file:
ret
# Terminates the program. a0 contains the return code.
+.type _exit, @function
exit:
li a7, SYS_EXIT
ecall
+
+# Writes a character from a0 into the standard output.
+.type _put_char, @function
+_put_char:
+ # Prologue
+ addi sp, sp, -16
+ sw ra, 12(sp)
+ sw s0, 8(sp)
+ addi s0, sp, 16
+
+ sb a0, 4(sp)
+ li a0, STDOUT
+ addi a1, sp, 4
+ li a2, 1
+ li a7, SYS_WRITE
+ ecall
+
+ # Epilogue.
+ lw ra, 12(sp)
+ lw s0, 8(sp)
+ add sp, sp, 16
+ ret