如何在 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/