GNU >> Assembly (RISC-V 64)

hello, world! (printf)


參考資訊:
1. syscall
2. debian-mips-tutorial

main.s

    .global main
    .extern printf
 
    .data
msg: .asciz "hello, world!\n"
 
    .text
main:
    add sp, sp, -4
    sw ra, 0(sp)
 
    la a0, msg
    jal printf
 
    lw ra, 0(sp)
    add sp, sp, 4
    jr ra

編譯、執行

$ riscv64-linux-gnu-gcc main.s -o main -static
$ qemu-riscv64 ./main
    hello, world!


返回上一頁