參考資訊:
https://flatassembler.net/index.php
http://kerseykyle.com/articles/ARM-assembly-hello-world
https://github.com/kevinhooke/learning-arm-asm/blob/master/helloworld.s
https://chromium.googlesource.com/chromiumos/docs/+/HEAD/constants/syscalls.md
System Call (EABI)
| NR | syscall name | r7 | arg0(r0) | arg1(r1) | arg2(r2) |
|---|---|---|---|---|---|
| 1 | exit | 1 | int error_code | ||
| 4 | write | 4 | unsigned int fd | const char *buf | size_t count |
main.s
format elf executable 3
entry start
segment readable executable
start:
mov r7, 4
mov r0, 1
mov r1, msg
mov r2, len
swi 0
mov r7, 1
mov r0, 0
swi 0
segment readable writeable
msg db "hello, world!", 10
len = $ - msg
編譯、執行
$ qemu-i386 /usr/local/bin/fasmarm main.s
$ qemu-arm-static ./main
hello, world!