smcc/linker/riscv32_crt.c
2025-04-01 00:13:21 +08:00

22 lines
481 B
C

#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;
}