hzq$ nasm -f macho64 -o helloworld aa.asm
hzq$ ld -o helloworld.o -e _start helloworld
ld: warning: No version-min specified on command line
ld: dynamic main executables must link with libSystem.dylib for inferred architecture x86_64
hzq$ ld -macosx_version_min 10.14 -o helloworld.o -e _start helloworld
ld: dynamic main executables must link with libSystem.dylib for inferred architecture x86_64
加上libSystem.dylib动态库,因为我们是在系统上编程,所以要用系统的接口,需要系统库
hzq$ ld -macosx_version_min 10.14 -o helloworld.o -e _start helloworld -lSystem
-e _start 是指定入口函数,由global声明
hzq$ ./helloworld.o
Enter a character: a
You have input: a
hzq$