參考資訊:
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
main.s
.global _start .data msg: .ascii "hello, world!\n" len = . - msg .text _start: mov r7, #4 mov r0, #1 ldr r1, =msg ldr r2, =len swi 0 mov r7, #1 mov r0, #0 swi 0
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 |
編譯、執行
$ arm-linux-gnueabihf-gcc main.s -o main -nostdlib -static $ qemu-arm ./main hello, world!