Step1: build with busybox.

Signed-off-by: Chen Wang <wangchen20@iscas.ac.cn>
This commit is contained in:
2025-11-24 16:22:33 +08:00
committed by Chen Wang
commit d35682f2b7
163 changed files with 15660 additions and 0 deletions

79
package/opensbi/hello.s Normal file
View File

@@ -0,0 +1,79 @@
# hello.s - RISC-V 64 , "hello world!"
.section .text
.global _start
_start:
# 0x80000000 <- OpenSBI
# 0x80200000 <- hello.bin
# 0x80210000 <-
#
li sp, 0x80210000
#
call print_hello
# 退 qemu Ctrl+A X
1: j 1b
# "hello world!"
print_hello:
#
addi sp, sp, -8
sd ra, 0(sp)
#
la a0, hello_string
#
call puts
#
ld ra, 0(sp)
addi sp, sp, 8
ret
# void puts(char *str)
# a0:
puts:
#
addi sp, sp, -16
sd ra, 8(sp)
sd s0, 0(sp)
mv s0, a0 #
PRINT_LOOP:
#
lb a0, 0(s0)
beq a0, zero, PRINT_DONE # '\0'
#
call putc
#
addi s0, s0, 1
j PRINT_LOOP
PRINT_DONE:
#
ld s0, 0(sp)
ld ra, 8(sp)
addi sp, sp, 16
ret
# void putc(char c)
# a0:
putc:
# 使 SBI (console_putchar)
li a7, 0x01 # SBI_EXT_0_1_CONSOLE_PUTCHAR
ecall
ret
#
.section .rodata
hello_string:
.asciz "\nHello RISC-V world!\n"
# 4
.align 2