c++ - 在 64 位、VS2008、C++ 中替换 _asm nop

标签 c++ visual-studio-2008 64-bit

如何在 64 位中替换 _asm nop 指令。在 32 位中编译和工作。

最佳答案

我相信您可以使用 __nop 内部函数。这应该编译成适用于您正在构建的处理器的机器指令。

http://msdn.microsoft.com/en-us/library/aa983381(VS.80).aspx

更新:

这是我刚刚用 VS2008 创建的示例。它针对 Win32 和 x64 配置进行编译:

#include "stdafx.h"
#include <intrin.h>

int _tmain(int argc, _TCHAR* argv[])
{
    // The intrinsic function below will compile to a NOP machine instruction.
    // This is the same as _asm nop in the 32-bit compiler.
    __nop();
    return 0;
}

如果您想知道,我反汇编了上面的示例,x64 输出为:

wmain    proc near
         db    66h
         nop
         nop
         xor   eax, eax
         retn
wmain    endp

Win32 输出是:

_main    proc near
        nop
        xor    eax, eax
        retn
_main   endp

关于c++ - 在 64 位、VS2008、C++ 中替换 _asm nop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2321070/

相关文章:

c++ - WaitForMultipleObjects 在 64 位 Windows 上崩溃

c++ - 将 char * 作为参数传递

c++ - 在 C++ 流中包装 C 风格的文件

c++ - 如何删除继承的私有(private) char* 属性? (例如 : in a destructor)

css - 如何更正 Visual Studio 中的 CSS 格式问题

c# - ASP.Net Response.Close 问题

visual-studio - 一次更新解决方案中所有项目的引用路径

64-bit - MacOS Catalina 上的 ld64 segprot 不起作用?

ios - 使用#define 变量创建 NSNumber

c++ - 堆栈模板不编译推送功能