【发布时间】:2011-05-31 17:31:39
【问题描述】:
如何使用 Visual Studio 编译汇编代码?
我想在Visual Studio 2010中编译并运行一个汇编源文件。
我创建了一个 Visual C++ 项目并在文件code.asm 中插入了一些汇编代码:
.586 ;Target processor. Use instructions for Pentium class machines
.MODEL FLAT, C ;Use the flat memory model. Use C calling conventions
.STACK ;Define a stack segment of 1KB (Not required for this example)
.DATA ;Create a near data segment. Local variables are declared after
;this directive (Not required for this example)
.CODE ;Indicates the start of a code segment.
clear PROC
xor eax, eax
xor ebx, ebx
ret
clear ENDP
END
但问题是当你尝试编译它时,你会得到:
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
我确实去启用了构建自定义masm.targets(右键单击项目>构建自定义..),但无济于事。
【问题讨论】:
-
并使用 Visual Studio 调试 asm(查看寄存器和从断点单步执行):stackoverflow.com/questions/46394685/…。另请参阅the x86 tag wiki 中的其他 x86 asm 链接。
标签: windows visual-studio-2010 assembly