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



參考資訊:
https://chromium.googlesource.com/chromiumos/docs/+/HEAD/constants/syscalls.md
https://github.com/matja/asm-examples/blob/master/aarch64/hello.aarch64.linux.syscall.gas.asm

main.s

    .global _start

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

    .text
_start:
    mov x8, #64
    mov x0, #1
    ldr x1, =msg
    ldr x2, =len
    svc #0

    mov x8, #93
    mov x0, #0
    svc #0

NRsyscall namex8arg0(x0)arg1(x1)arg2(x2)
64write4unsigned int fdconst char *bufsize_t count
93exit1int error_code

編譯、執行

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