我試圖在Linux中使用as和gcc編譯RISC V彙編。
模擬器是TinyEmu.busybox擁有所有實用程序--TinyEmu
鏡像為diskimage-linux-riscv- 2018-09-23 .
我可以編譯該程序,但是控制台上沒有輸出內容。.section .text
.globl _start
_start:
li a0, 0 # stdout
1: auipc a1, %pcrel_hi(msg) # load msg(hi)
addi a1, a1, %pcrel_lo(1b) # load msg(lo)
li a2, 12 # length
li a3, 0
li a7, 64 # _NR_sys_write
ecall # system call
li a0, 0
li a1, 0
li a2, 0
li a3, 0
li a7, 93 # _NR_sys_exit
ecall # system call
loop:
j loop
.section .rodata
msg:
.string"Hello Worldn"
我已經嘗試了as和gcc調用的幾種組合:as -o hello.o hello.s
ld as -o hello.o hello.s
這將創建一個二進位文件,但是沒有控制台輸出。