I was also able to get this assembly language hello world to work:
// Hello World for Big Sur
.text
_helloworldmsg:
.asciz "Hello World!\n"
.globl _myhelloworldstart
_myhelloworldstart:
// syscall is deprecated.
// Last I checked, if you use syscall, the assembler compiles an imported function call.
// If you hard code the syscall opcode, macos will not execute it and will give you an error
// so I am using imported function calls to access the system library functions.
andq $0xfffffffffffffff0, %rsp // Force alignment. Without this exit will seg fault.
movq $1, %rdi
leaq _helloworldmsg(%rip), %rsi
movq $13, %rdx
call _write
xorq %rdi, %rdi // clear rdi to return success
call _exit
using these commands:
as -mmacosx-version-min=10.11 ./helloworldbigsur.s -o helloworldbigsur.o
ld -e myhelloworldstart -nouuid -noehlabels -demangle -dynamic -arch x8664 -platformversion macos 11.0.0 11.1 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -o helloworldbigsur -L/usr/local/lib helloworldbigsur.o -lSystem
Topic:
Developer Tools & Services
SubTopic:
General
Tags: