程式語言 - GNU - Assembly (ARM 64) - Hello, world!(printf)



參考資訊:
https://stackoverflow.com/questions/64638627/explain-arm64-instruction-stp
https://chromium.googlesource.com/chromiumos/docs/+/HEAD/constants/syscalls.md

main.s

    .global main
    .extern printf

    .data
msg: .asciz "hello, world!\n"

    .text
main:
    stp x29, x30, [sp, #-0x10]!

    ldr x0, =msg
    bl printf
    mov x0, #0

    ldp x29, x30, [sp], #0x10
    ret

編譯、執行

$ aarch64-linux-gnu-gcc main.s -o main -static
$ qemu-aarch64 ./main
    hello, world!