This commit is contained in:
ZZY
2025-04-01 00:13:21 +08:00
parent 2b4857001c
commit 74f43a1ab7
79 changed files with 2271 additions and 2861 deletions

21
linker/riscv32_crt.c Normal file
View File

@@ -0,0 +1,21 @@
#include "header.h"
// #include <assembler/riscv32/riscv32.c>
rv32_prog_t* gen_rv32_crt() {
rv32_prog_t* crt = (rv32_prog_t*)salloc_alloc(sizeof(rv32_prog_t));
init_rv32_prog(crt, NULL);
rv32_li(crt, REG_SP, 0x1000);
rv32_li(crt, REG_RA, 0x0);
// call main
symasm_entry_t entry = {
.name = "main",
.attr = GLOBAL
};
rv32_call_l(crt, &entry);
// ecall exit2
rv32_li(crt, REG_A7, 93);
rv32_ecall(crt);
return crt;
}