Unify taking an identifier address

This commit is contained in:
2025-05-12 23:07:02 +02:00
parent d85183c7a6
commit 1b31f532df
3 changed files with 100 additions and 180 deletions

View File

@@ -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