summaryrefslogtreecommitdiff
path: root/boot/common-boot.s
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2025-04-29 23:08:46 +0200
committerEugen Wissner <belka@caraus.de>2025-04-29 23:08:46 +0200
commit23b7a1ab308442777a32c3bd123e68ad98369c42 (patch)
tree5b2ea7e933d50a9dd150568f1aafd3bad60db073 /boot/common-boot.s
parent9c66cec171bafaf12713efb78ac6099ef1f23020 (diff)
downloadelna-23b7a1ab308442777a32c3bd123e68ad98369c42.tar.gz
Support preserved registers as identifiers
… in expressions
Diffstat (limited to 'boot/common-boot.s')
-rw-r--r--boot/common-boot.s21
1 files changed, 17 insertions, 4 deletions
diff --git a/boot/common-boot.s b/boot/common-boot.s
index e8eba52..e5796f1 100644
--- a/boot/common-boot.s
+++ b/boot/common-boot.s
@@ -1,5 +1,6 @@
.global _is_alpha, _is_digit, _is_alnum, _is_upper, _is_lower
-.global _write_out, _read_file, _memcmp, _write_error, _put_char, _printi
+.global _write_out, _read_file, _write_error, _put_char, _printi
+.global _get, _memcmp
.global _divide_by_zero_error, _exit
.section .rodata
@@ -187,7 +188,9 @@ _write_out:
# a0 - Buffer pointer.
# a1 - Buffer size.
#
-# Returns the result in a0.
+# Sets s1 to the buffer passed in a0.
+#
+# Returns the amount of bytes written in a0.
.type _read_file, @function
_read_file:
# Prologue.
@@ -196,9 +199,11 @@ _read_file:
sw s0, 0(sp)
addi s0, sp, 8
- mv a2, a1
- mv a1, a0
+ mv s1, a0
+
li a0, STDIN
+ mv a2, a1
+ mv a1, s1
li a7, SYS_READ
ecall
@@ -293,3 +298,11 @@ _put_char:
lw s0, 8(sp)
add sp, sp, 16
ret
+
+# a0 - Pointer to an array to get the first element.
+#
+# Dereferences a pointer and returns what is on the address in a0.
+.type _get, @function
+_get:
+ lw a0, (a0)
+ ret