From 23b7a1ab308442777a32c3bd123e68ad98369c42 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Tue, 29 Apr 2025 23:08:46 +0200 Subject: Support preserved registers as identifiers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … in expressions --- boot/common-boot.s | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'boot/common-boot.s') 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 -- cgit v1.2.3