GNU >> Assembly (RISC-V 64)

hello, world! (ecall)


參考資訊:
1. syscall
2. debian-mips-tutorial
3. risc-v-assembly-language-hello-world

main.s

    .global _start

    .data
msg: .asciz "hello, world!\n"
len = . - msg

    .text
_start:
    li a7, 64
    li a0, 1
    la a1, msg
    li a2, len
    ecall

    li a7, 93
    li a0, 0
    ecall

NRsyscall namea7arg0(a0)arg1(a1)arg2(a2)
64write4unsigned int fdconst char *bufsize_t count
93exit1int error_code

編譯、執行

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


返回上一頁