将Visual Studio 2017中的Assembly和C ++与命令行和输出结合 [英] Combining Assembly and C++ in Visual Studio 2017 with the command line and outputs

查看:178
本文介绍了将Visual Studio 2017中的Assembly和C ++与命令行和输出结合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将这些语言结合起来以进行测试.有谁知道为什么,在生成项目后,当.asm文件位于源文件夹中时,找不到清除功能.下面显示的以下图像应解释我的要求,我将进行进一步的编辑.

I am trying to combine these languages for testing purposes. Does anyone know why, after building the project the clear function cannot be found when the .asm file is in the source folder. The following images shown below should explain what I am asking and I will edit further.

带有程序集和C ++文件的Visual Studio

上一张照片显示了我的.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 

推荐答案

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

If you skipped the default, you need to create a custom build step. Right click on the assembly source file name, then properties / custom build step and enter command line and outputs fields:

用于调试版本:

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:

Also you may need to declare clear as public in the assembly source file:

        public  clear

对于64位版本,请使用ml64代替ml.

For a 64 bit build, use ml64 instead of ml.

我通常通过创建一个空项目"来开始一个新项目,然后添加现有项目(源文件)以避免VS创建的默认项目.

I generally start a new project by creating an "empty project", then adding existing items (source file) to avoid the default stuff created by VS.

这篇关于将Visual Studio 2017中的Assembly和C ++与命令行和输出结合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆