将Visual Studio 2017中的Assembly和C ++与命令行和输出相结合

问题描述 投票:1回答:1

我正在尝试将这些语言结合起来用于测试目的。有没有人知道为什么,在构建项目后,当.asm文件在源文件夹中时,无法找到clear函数。下面显示的以下图像应该解释我的要求,我将进一步编辑。

Visual Studio with an assembly and C++ file

this last photo shows the properties from my .asm file

.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 
assembly visual-c++ x86 visual-studio-2017 masm
1个回答
0
投票

如果跳过默认值,则需要创建自定义构建步骤。右键单击程序集源文件名,然后右键单击属性/自定义构建步骤并输入命令行和输出字段:

用于调试版本:

command: ml /Zi /c /Fo$(outdir)\example.obj example.asm
output: $(outdir)\example.obj

发布版本:

command: ml /c /Fo$(outdir)\example.obj example.asm
output: $(outdir)\example.obj

您还可能需要在汇编源文件中将clear声明为public:

        public  clear

对于64位构建,请使用ml64而不是ml。

我通常通过创建一个“空项目”,然后添加现有项目(源文件)来启动一个新项目,以避免由VS创建的默认内容。

© www.soinside.com 2019 - 2024. All rights reserved.