mac 下使用nasm

 

#安装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
相关文章
相关标签/搜索