summaryrefslogtreecommitdiff
path: root/boot/common-boot.s
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2025-05-12 23:07:02 +0200
committerEugen Wissner <belka@caraus.de>2025-05-12 23:07:02 +0200
commit1b31f532dfb9987788565c90db0558db6f8bed30 (patch)
treec57ceeb963430268429dadf891ce32c4d91512e9 /boot/common-boot.s
parentd85183c7a6842a4db83635c64cf85ddf37491971 (diff)
downloadelna-1b31f532dfb9987788565c90db0558db6f8bed30.tar.gz
Unify taking an identifier address
Diffstat (limited to 'boot/common-boot.s')
-rw-r--r--boot/common-boot.s36
1 files changed, 33 insertions, 3 deletions
diff --git a/boot/common-boot.s b/boot/common-boot.s
index 0c2ef6b..f61321e 100644
--- a/boot/common-boot.s
+++ b/boot/common-boot.s
@@ -4,9 +4,9 @@
.global _is_alpha, _is_digit, _is_alnum, _is_upper, _is_lower
.global _write_s, _read_file, _write_error, _write_c, _write_i, _print_i
-.global _get, _memcmp, _memchr, _memmem, _memcpy
-.global _divide_by_zero_error, _exit, _mmap
-.global _strings_index, _string_equal
+.global _memcmp, _memchr, _memmem, _memcpy, _mmap
+.global _current, _get, _advance, _label_counter
+.global _divide_by_zero_error, _exit, _strings_index, _string_equal
.section .rodata
@@ -598,3 +598,33 @@ _mmap:
ecall
ret
+
+# Sets the a0 to the current position in the source text (s1).
+.type _current, @function
+_current:
+ mv a0, s1
+ ret
+
+# Advances the position of the source text.
+#
+# Parameters:
+# a0 - The number of bytes to advance.
+.type _advance, @function
+_advance:
+ add s1, s1, a0
+ ret
+
+# Advances the global label counter by 1 setting a0 to the previous value.
+#
+# Parameters:
+# a0 - If it is 0, resets the counter to 1.
+.type _label_counter, @function
+_label_counter:
+ bnez a0, .Llabel_counter_advance
+ li s2, 0
+
+.Llabel_counter_advance:
+ mv a0, s2
+ addi s2, s2, 1
+
+ ret