mirror of
https://github.com/plctlab/riscv-operating-system-mooc.git
synced 2025-12-05 15:15:49 +00:00
- https://gitee.com/unicornx/riscv-operating-system-mooc/issues/I4QLTP - https://gitee.com/unicornx/riscv-operating-system-mooc/issues/I4PJTQ - https://gitee.com/unicornx/riscv-operating-system-mooc/issues/I49VW5 Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
29 lines
518 B
ArmAsm
29 lines
518 B
ArmAsm
# ASM call C
|
|
|
|
.text # Define beginning of text section
|
|
.global _start # Define entry _start
|
|
.global foo # foo is a C function defined in test.c
|
|
|
|
_start:
|
|
la sp, stack_end # prepare stack for calling functions
|
|
|
|
# RISC-V uses a0 ~ a7 to transfer parameters
|
|
li a0, 1
|
|
li a1, 2
|
|
call foo
|
|
# RISC-V uses a0 & a1 to transfer return value
|
|
# check value of a0
|
|
|
|
stop:
|
|
j stop # Infinite loop to stop execution
|
|
|
|
nop # just for demo effect
|
|
|
|
stack_start:
|
|
.rept 12
|
|
.word 0
|
|
.endr
|
|
stack_end:
|
|
|
|
.end # End of file
|