Steward
分享是一種喜悅、更是一種幸福
程式語言 - GNU - Assembly (ARM 64) - Hello, world!(svc)
參考資訊:
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | . 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!