在Visual Studio编译大会 [英] Compiling Assembly in Visual Studio
问题描述
你如何使用VS编译装配code?
How do you compile assembly code using VS?
我想要做的就是编译并在Visual Studio 2010中运行汇编源文件是什么。
What I want to do is compile and run an assembly source file in Visual Studio 2010.
我创建了一个VC ++项目,并在文件中插入一些汇编code code.asm
。
I've created a VC++ project, and inserted some assembly code in a file 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
但问题是,当你尝试编译这个,你得到
However the problem is when you try and compile this, you get
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
我没去,使构建定制 masm.targets
(右键单击项目>生成自定义..),但无济于事。
I did go and enable the build customization masm.targets
(right click project > Build Customizations..) but to no avail
推荐答案
听起来好像自定义生成未启用.ASM文件的规则。右键单击该项目,自定义生成规则,勾选Microsoft宏汇编程序。随着清底指令和禁用增量链接我得到一个干净的构建。
Sounds to me like the custom build rules for .asm files isn't enabled. Right-click the project, Custom Build Rules, tick "Microsoft Macro Assembler". With the "END clear" directive and disabling incremental linking I'm getting a clean build.
这对VS2010不同。用鼠标右键单击项目,创建自定义设置,勾选MASM。右键单击该文件.ASM,属性,改变项目类型为Microsoft宏汇编程序。
It's different for VS2010. Right-click project, Build customizations, tick "masm". Right-click the .asm file, Properties, change Item Type to "Microsoft Macro Assembler".
这篇关于在Visual Studio编译大会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!