To compile:
as -o hello.o hello.s
ld -o hello hello.o -lSystem -syslibroot `xcrun -sdk macosx --show-sdk-path` -e _main -arch arm64
./hello
.global _main | |
.align 2 | |
_main: | |
mov x0, #1 // file descriptor (1 for stdout) | |
adrp x1, message@PAGE // load the address of the string | |
add x1, x1, message@PAGEOFF | |
mov x2, #14 // length | |
mov x16, #0x04 // syscall number for write | |
svc 0 // make the syscall | |
mov x0, #0 // exit code 0 | |
mov x16, #0x01 // syscall number for exit | |
svc 0 // make the syscall | |
.section __TEXT,__cstring | |
message: | |
.asciz "Hello, World!\n" |