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



參考資訊:
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)

NRsyscall namer7arg0(r0)arg1(r1)arg2(r2)
1exit1int error_code
4write4unsigned int fdconst char *bufsize_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!