解决lb lh 指令没有进行符号扩展的问题

This commit is contained in:
2025-04-17 23:36:44 +08:00
parent 46d1e933f5
commit 29019b9b98
9 changed files with 166 additions and 22 deletions

View File

@@ -2,7 +2,7 @@
import os
import sys
import time
import shutil
@@ -29,6 +29,7 @@ CFLAG=[
SRC=[
"riscv/main.c",
"riscv/test.c",
"riscv/start.S"
]
@@ -36,7 +37,16 @@ LD_FILE="riscv.ld"
TARGET="riscv"
OUTPUT="output"
if __name__ == "__main__":
if not os.path.exists(OUTPUT):
os.mkdir(OUTPUT)
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"{OBJCPY} -O ihex {TARGET}.elf {TARGET}.hex")
os.system(f"{OBJDUMP} -d {TARGET}.elf > {TARGET}.lst")
tagets_list=[f"{TARGET}.bin",f"{TARGET}.hex",f"{TARGET}.lst",f"{TARGET}.map",f"{TARGET}.elf"]
for item in tagets_list:
if os.path.exists(item):
shutil.move(item,f"{OUTPUT}/{item}")