參考資訊:
https://chromium.googlesource.com/chromiumos/docs/+/HEAD/constants/syscalls.md
https://github.com/matja/asm-examples/blob/master/aarch64/hello.aarch64.linux.syscall.gas.asm
main.s
.global _start .data msg: .asciz "hello, world!\n" len = . - msg .text _start: mov x8, #64 mov x0, #1 ldr x1, =msg ldr x2, =len svc #0 mov x8, #93 mov x0, #0 svc #0
NR | syscall name | x8 | arg0(x0) | arg1(x1) | arg2(x2) |
---|---|---|---|---|---|
64 | write | 4 | unsigned int fd | const char *buf | size_t count |
93 | exit | 1 | int error_code |
編譯、執行
$ aarch64-linux-gnu-gcc main.s -o main -nostdlib -static $ qemu-aarch64 ./main hello, world!