參考資訊:
https://gist.github.com/bellbind/753290
https://syscalls.w3challs.com/?arch=arm_strong
http://kerseykyle.com/articles/ARM-assembly-hello-world
https://github.com/kevinhooke/learning-arm-asm/blob/master/helloworld.s
https://stackoverflow.com/questions/48183434/implementation-of-syscall-on-arm-oabi-what-is-svc-0x900071
main.s
.global _start
.data
msg: .ascii "hello, world!\n"
len = . - msg
.text
_start:
mov r0, #1
ldr r1, =msg
ldr r2, =len
swi 0x900004
mov r0, #0
swi 0x900001
| NR | syscall name | arg0(r0) | arg1(r1) | arg2(r2) |
|---|---|---|---|---|
| 0x900001 | exit | int error_code | ||
| 0x900004 | write | unsigned int fd | const char *buf | size_t count |
編譯、執行
$ arm-linux-gnueabihf-gcc main.s -o main -nostdlib -static
$ qemu-arm ./main
hello, world!