程式語言 - Flat Assembler (FASM) - Assembly (ARM) - Hello, world!(swi, oabi)



參考資訊:
https://flatassembler.net/index.php
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

System Call (OABI)

NRsyscall namearg0(r0)arg1(r1)arg2(r2)
0x900001exitint error_code
0x900004writeunsigned int fdconst char *bufsize_t count

main.s

    format elf executable 3
    entry start
 
    segment readable executable
start:
    mov r0, 1
    mov r1, msg
    mov r2, len
    swi 0x900004
 
    mov r0, 0
    swi 0x900001

    segment readable writeable
msg db "hello, world!", 10
len = $ - msg

編譯、執行

$ qemu-i386 /usr/local/bin/fasmarm main.s
$ qemu-arm-static ./main
    hello, world!