我不知道如何编写汇编或编译它。我相信这段代码适用于“hello world”示例;
section .text
global _start ;must be declared for using gcc
_start: ;tell linker entry point
mov edx, len ;message length
mov ecx, msg ;message to write
mov ebx, 1 ;file descriptor (sftdout)
mov eax, 4 ;system call number (sys_write)
int 0x80 ;call kernel
mov eax, 1 ;system call number (sys_exit)
int 0x80 ;call kernel
section .data
msg db 'Hello, world!',0xa ;our dear string
len equ $ - msg ;length of our dear string
我想使用sublime text 3构建它。我有这个构建文件;
{
"shell": true,
"cmd": ["nasm -f macho ${file} && gcc -arch i386 -o ${file_path}/${file_base_name} ${file_path}/${file_base_name}.o"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
}
我收到此错误;
clang: error: linker command failed with exit code 1
此设置有什么问题?
答案 0 :(得分:2)
试试这个:
"shell": true,
"cmd": ["nasm -f elf64 ${file} && ld -s -o ${file_base_name} ${file_base_name}.o"],
"file_regex": "^(.+):([0-9]+)()?: error: (.*)$",
"working_dir": "${file_path}",
"selector": "source.assembly"