添加基础指令解析和运行

This commit is contained in:
2025-04-17 00:04:59 +08:00
parent 5aec6bced8
commit be8c08f176
4 changed files with 288 additions and 4 deletions

37
make_riscv.py Normal file
View File

@@ -0,0 +1,37 @@
import os
import sys
import time
CC="riscv64-unknown-elf-gcc"
OBJ="riscv64-unknown-elf-objcopy"
CFLAG=[
"-march=rv32i",
"-mabi=ilp32",
"-ffunction-sections",
"-fdata-sections",
"-ffast-math",
"-fno-common",
"-fno-builtin-printf",
"-Wall",
"-Werror",
"-g",
"-Os",
"-fno-omit-frame-pointer",
"-msave-restore"
]
SRC=[
"riscv/main.c"
]
TARGET="riscv"
if __name__ == "__main__":
os.system(f"{CC} {' '.join(CFLAG)} {' '.join(SRC)} -o {TARGET}.elf")
os.system(f"{OBJ} -O binary {TARGET}.elf {TARGET}.bin")