Last active
August 29, 2015 14:21
-
-
Save liuxinglanyue/0135c7de28d229e23c28 to your computer and use it in GitHub Desktop.
在Mac上执行汇编程序,配置Sublime Text的编译环境
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; /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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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}"] | |
} | |
] | |
} |
Mac上nasm版本较低,可通过brew install nasm安装
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sublime 安装NASM,并修改$HOME/Library/Application Support/Sublime Text 2/Packages/NASM x86 Assembly/NASM.sublime-build