Skip to content

Instantly share code, notes, and snippets.

@liuxinglanyue
Last active August 29, 2015 14:21
Show Gist options
  • Save liuxinglanyue/0135c7de28d229e23c28 to your computer and use it in GitHub Desktop.
Save liuxinglanyue/0135c7de28d229e23c28 to your computer and use it in GitHub Desktop.
在Mac上执行汇编程序,配置Sublime Text的编译环境
; /usr/local/bin/nasm -f macho64 hello.asm && ld -macosx_version_min 10.7.0 -o hello hello.o && ./hello
global start
section .text
start:
mov rax, 0x2000004 ; write
mov rdi, 1 ; stdout
; mov rsi,msg
lea rsi, [rel msg]
mov rdx, msg.len
syscall
mov rax, 0x2000001 ; exit
mov rdi, 0
syscall
section .data
msg: db "Hello, world!", 10
.len: equ $ - msg
{
"cmd": ["nasm", "-f", "macho64", "${file}"],
"file_regex": "a(sm)?$",
"working_dir": "${file_path}",
"selector": "untitled.asm",
"variants":
[
{
"name": "Run",
"shell": "true",
"cmd": ["nasm -f macho64 ${file} && ld -macosx_version_min 10.7.0 -o ${file_base_name} ${file_base_name}.o && ${file_path}/${file_base_name}"]
}
]
}
@liuxinglanyue
Copy link
Author

Sublime 安装NASM,并修改$HOME/Library/Application Support/Sublime Text 2/Packages/NASM x86 Assembly/NASM.sublime-build

@liuxinglanyue
Copy link
Author

Mac上nasm版本较低,可通过brew install nasm安装

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment