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
NR | syscall name | a7 | arg0(a0) | arg1(a1) | arg2(a2) |
---|---|---|---|---|---|
64 | write | 4 | unsigned int fd | const char *buf | size_t count |
93 | exit | 1 | int error_code |
編譯、執行
$ riscv64-linux-gnu-gcc main.s -o main -static -nostdlib $ qemu-riscv64 ./main hello, world!