visual-studio 使用 Visual Studio 2008 组装、链接、调试和执行 MASM 6.11 汇编代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/112412/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using Visual Studio 2008 to Assemble, Link, Debug, and Execute MASM 6.11 Assembly Code
提问by Kreychek
I would like to use Visual Studio 2008 to the greatest extent possible while effectively compiling/linking/building/etc code as if all these build processes were being done by the tools provided with MASM 6.11. The exact version of MASM does not matter, so long as it's within the 6.x range, as that is what my college is using to teach 16-bit assembly.
我想最大程度地使用 Visual Studio 2008,同时有效地编译/链接/构建/等代码,就好像所有这些构建过程都是由 MASM 6.11 提供的工具完成的。MASM 的确切版本并不重要,只要它在 6.x 范围内即可,因为我的大学正在使用它来教授 16 位汇编。
I have done some research on the subject and have come to the conclusion that there are several options:
我对该主题进行了一些研究,并得出以下结论:有几种选择:
- Reconfigure VS to call the MASM 6.11 executables with the same flags, etc as MASM 6.11 would natively do.
- Create intermediary batch file(s) to be called by VS to then invoke the proper commands for MASM's linker, etc.
- Reconfigure VS's built-in build tools/rules (assembler, linker, etc) to provide an environment identical to the one used by MASM 6.11.
- 重新配置 VS 以调用 MASM 6.11 可执行文件,其标志等与 MASM 6.11 本身会做的相同。
- 创建由 VS 调用的中间批处理文件,然后为 MASM 的链接器等调用正确的命令。
- 重新配置 VS 的内置构建工具/规则(汇编器、链接器等),以提供与 MASM 6.11 使用的环境相同的环境。
Option (2) was brought up when I realized that the options available in VS's "External Tools" interface may be insufficient to correctly invoke MASM's build tools, thus a batch file to interpret VS's strict method of passing arguments might be helpful, as a lot of my learning about how to get this working involved my manually calling ML.exe, LINK.exe, etc from the command prompt.
当我意识到 VS 的“外部工具”界面中可用的选项可能不足以正确调用 MASM 的构建工具时,提出了选项 (2),因此解释 VS 传递参数的严格方法的批处理文件可能会有所帮助,因为很多我学习如何使这项工作涉及我从命令提示符手动调用 ML.exe、LINK.exe 等。
Below are several links that may prove useful in answering my question. Please keep in mind that I have read them all and none are the actual solution. I can only hope my specifying MASM 6.11 doesn't prevent anyone from contributing a perhaps more generalized answer.
以下是几个可能有助于回答我的问题的链接。请记住,我已经阅读了所有内容,但没有一个是实际的解决方案。我只能希望我指定的 MASM 6.11 不会阻止任何人提供可能更笼统的答案。
Similar method used to Option (2), but users on the thread are not contactable:
http://www.codeguru.com/forum/archive/index.php/t-284051.html
(also, I have my doubts about the necessity of an intermediary batch file)
用于选项(2)的类似方法,但无法联系线程上的用户:
http: //www.codeguru.com/forum/archive/index.php/t-284051.html
(另外,我对中间批处理文件的必要性)
Out of date explanation to my question:
http://www.cs.fiu.edu/~downeyt/cop3402/masmaul.html
对我的问题的过时解释:http:
//www.cs.fiu.edu/~downeyt/cop3402/masmaul.html
Probably the closest thing I've come to a definitive solution, but refers to a suite of tools from something besides MASM, also uses a batch file:
http://www.kipirvine.com/asm/gettingStarted/index.htm#16-bit
可能是我最接近最终解决方案的东西,但指的是除 MASM 之外的一套工具,还使用了一个批处理文件:http:
//www.kipirvine.com/asm/gettingStarted/index.htm#16 -少量
I apologize if my terminology for the tools used in each step of the code -> exe process is off, but since I'm trying to reproduce the entirety of steps in between completion of writing the code and generating an executable, I don't think it matters much.
如果我在代码的每个步骤中使用的工具的术语 -> exe 进程关闭,我深表歉意,但由于我试图重现完成编写代码和生成可执行文件之间的整个步骤,我不认为这很重要。
采纳答案by Sam Harwell
There is a MASM rules file located at (32-bit system remove (x86)):
有一个 MASM 规则文件位于(32 位系统删除(x86)):
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\VCProjectDefaults\masm.rules
Copy that file to your project directory, and add it to the Custom Build Rules for your project. Then "Modify Rule File...", select the MASM build rule and "Modify Build Rule...".
将该文件复制到您的项目目录,并将其添加到您的项目的自定义构建规则中。然后“修改规则文件...”,选择 MASM 构建规则和“修改构建规则...”。
Add a property:
添加属性:
- User property type: String
- Default value: *.inc
- Description: Add additional MASM file dependencies.
- Display name: Additional Dependencies
- Is read only: False
- Name: AdditionalDependencies
- Property page name: General
- Switch: [value]
- 用户属性类型:字符串
- 默认值:*.inc
- 描述:添加额外的 MASM 文件依赖项。
- 显示名称:附加依赖项
- 是否只读:假
- 名称:附加依赖项
- 属性页名称:General
- 开关:[值]
Set the Additional Dependencies value to [AdditionalDependencies]. The build should now automatically detect changes to *.inc, and you can edit the properties for an individual asm file to specify others.
将附加依赖项值设置为[AdditionalDependencies]。构建现在应该自动检测对 的更改*.inc,您可以编辑单个 asm 文件的属性以指定其他文件。
回答by Roger Lipscombe
You can create a makefile project. In Visual Studio, under File / New / Project, choose Visual C++ / Makefile project.
您可以创建一个 makefile 项目。在 Visual Studio 中,在文件/新建/项目下,选择 Visual C++/Makefile 项目。
This allows you to run an arbitrary command to build your project. It doesn't have to be C/C++. It doesn't even have to be a traditional NMake makefile. I've used it to compile a driver using a batch file, and using a NAnt script.
这允许您运行任意命令来构建您的项目。它不必是 C/C++。它甚至不必是传统的 NMake 生成文件。我用它来编译一个使用批处理文件的驱动程序,并使用一个 NAnt 脚本。
It should be fairly easy to get it to run the MASM 6.x toolchain.
让它运行 MASM 6.x 工具链应该相当容易。
回答by tabdamage
I would suggest to define Custom Build rules depending on file extension. (Visual Studio 2008, at least in Professinal Edition, can generate .rules files, which can be distributed). There you can define custom build tools for asm files. By using this approach, you should be able to leave the linker step as is.
我建议根据文件扩展名定义自定义构建规则。(Visual Studio 2008,至少在Professinal Edition 中,可以生成可以分发的.rules 文件)。在那里您可以为 asm 文件定义自定义构建工具。通过使用这种方法,您应该能够保持链接器步骤不变。
Way back, we used MASM32 link textas IDE to help students learn assembly. You could check their batchfiles what they do to assemble and link.
过去,我们使用 MASM32链接文本作为 IDE 来帮助学生学习汇编。您可以检查他们的批处理文件,他们如何组装和链接。
回答by shoosh
instead of batch files, why not use the a custom build step defined on the file?
而不是批处理文件,为什么不使用文件上定义的自定义构建步骤?
回答by R Caloca
If you are going to use Visual Studio, couldn't you give them a skeleton project in C/C++ with the entry point for a console app calling a function that has en empty inline assembly block, and let them fill their results in it?
如果您打算使用 Visual Studio,难道您不能给他们一个 C/C++ 框架项目,其中包含控制台应用程序的入口点,该应用程序调用具有空内联程序集块的函数,并让他们将结果填入其中吗?
回答by TCJ
Why don't you use Irvine's guide? Irvine's library is nice and if you want, you can ignore it and work with Windows procs directly. I've searching for a guide like this, Irvine's was the best solution.
你为什么不使用 Irvine 的指南?Irvine 的库很好,如果您愿意,可以忽略它并直接使用 Windows proc。我一直在寻找这样的指南,Irvine 是最好的解决方案。

