MASM64编译时检测体系结构

MASM64编译时检测体系结构

本文介绍了在MASM/MASM64编译时检测体系结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

如何在编译时从ASM源文件中检测目标体系结构是I386还是AMD64?

How can I detect at compile time from an ASM source file if the target architecture is I386 or AMD64?

我正在使用masm(ml.exe)/masm64(ml64.exe)组装file32.asm和file64.asm.创建单个文件file.asm会很好,根据架构的不同,该文件应包含file32.asm或file64.asm.理想情况下,我希望能够编写如下内容:

I am using masm(ml.exe)/masm64(ml64.exe) to assemble file32.asm and file64.asm. It would be nice to create a single file, file.asm, which should include either file32.asm, or file64.asm, depending on the architecture. Ideally, I would like to be able to write something like:


IFDEF amd64
include file64.asm
ELSE
include file32.asm
ENDIF

此外,如果需要,我可以使用不同的命令行选项运行ml.exe和ml64.exe.

Also, if needed, I can run ml.exe and ml64.exe with different command line options.

谢谢!

推荐答案

如果我对您的理解正确,那么您正在寻找某种内置定义,该定义在32位和64位MASM版本中具有不同的值.我曾经寻找过类似的东西,但没有找到合适的东西.

If I understand you correctly, you're looking for some sort of built-in define that has a different value among 32 and 64 bit MASM versions. I once looked for something like that, but didn't find anything suitable.

但是,只需定义自己的定义就很容易了,例如在源文件的开头选择AMD64 equ 1来选择所需的代码路径,或者在ML/ML64命令行上选择AMD64 equ 1.然后按照您的建议使用IFDEF/IFNDEF.

However, it's easy enough to just define your own, e.g. AMD64 equ 1 at the start of your source file to select your desired code path, or at the ML/ML64 command-line, like /DAMD64. And then use IFDEF/IFNDEF, as you suggest.

这篇关于在MASM/MASM64编译时检测体系结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 16:48