#安装nasm
brew install nasm

#创建文件
vi hello.asm
写入如下内容
msg: db "hello world!", 0x0a
len: equ $-msg
   
SECTION .text
global _main
   
kernel:
     syscall
     ret
  
_main:
     mov rax,0x2000004
     mov rdi,1
     mov rsi,msg
     mov rdx,len
     call kernel
   
     mov rax,0x2000001
     mov rdi,0
     call kernel


#编译
nasm -f macho64 -o hello.o hello.asm
#链接
ld hello.o -o hello -macosx_version_min 10.13 -lSystem
#运行
bogon:Desktop macname$ ./hello 
hello world!




参考:
https://www.cnblogs.com/Cindy632/p/10767100.html

 

相关文章:

  • 2021-12-11
  • 2021-10-03
  • 2021-05-30
  • 2021-10-30
  • 2021-10-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-30
  • 2022-01-05
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案