This commit is contained in:
2026-09-11 19:32:18 -04:00
parent 3187a3bd0b
commit 46406a2e87
2 changed files with 22 additions and 6 deletions
+15 -2
View File
@@ -1,9 +1,22 @@
.globl fetch_argc, fetch_argv
.data
sp_start: .space 8
.section .text
.globl save_sp, fetch_argc, fetch_argv
save_sp:
sd sp, sp_start, t0 # save the stack pointer
ret
# Fetch argument count
# @param[in] a0: unused.
# @param[out] a0: number of arguments.
fetch_argc:
ld a0, 0(sp)
ld t0, sp_start # dereference the buffer
ld a0, 0(t0) # dereference the address
ret
# Fetch argument value
# @param[in] a0: argv[a0].
# @param[out] a0: address of arg.
fetch_argv:
+5 -2
View File
@@ -1,5 +1,5 @@
.data
argc: .space 8
argc: .space 8
.section .text
.globl _start
@@ -10,12 +10,15 @@ _start:
la gp, __global_pointer$
.option pop
call save_sp
call fetch_argc
li t0, 48
add a0, a0, t0
sd a0, argc, t0
# li a0, 1
# call fetch_argv
li a0, 1
la a1, argc