模拟cpu成功运行

This commit is contained in:
2025-04-17 11:14:53 +08:00
parent ed0144b2ce
commit 1eb2785984
4 changed files with 183 additions and 11 deletions

View File

@@ -8,7 +8,8 @@ import time
CC="riscv64-unknown-elf-gcc"
OBJ="riscv64-unknown-elf-objcopy"
OBJCPY="riscv64-unknown-elf-objcopy"
OBJDUMP="riscv64-unknown-elf-objdump"
CFLAG=[
"-march=rv32i",
@@ -27,11 +28,15 @@ CFLAG=[
]
SRC=[
"riscv/main.c"
"riscv/main.c",
"riscv/start.S"
]
LD_FILE="riscv.ld"
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")
os.system(f"{CC} {' '.join(CFLAG)} {' '.join(SRC)} -T{LD_FILE} -Wall -Wextra -nostartfiles -Wl,-Map,\"{TARGET}.map\" -o {TARGET}.elf")
os.system(f"{OBJCPY} -O binary {TARGET}.elf {TARGET}.bin")
os.system(f"{OBJDUMP} -d {TARGET}.elf > {TARGET}.lst")