How to replace _asm nop
instructions in 64-bit. compiles and works in 32-bit.
views:
280answers:
2
+1
A:
You can't use _asm in a 64-bit program. The replacement is intrinsics, a list of instructions is available here. NOP isn't one of them, you'd have to use MASM64, available as vc\bin\x86_amd64\ml64.exe when you've got the 64-bit compilers installed.
Hans Passant
2010-02-23 19:52:47
ok, but it's inside C++, it compiles in VC++ 2008, I don't understand how am I suppose to use MASAM64 for this,..
ra170
2010-02-23 21:53:46
I'll put it another way: you cannot use inline assembly with _asm if you want to compile to x64. Post your _asm code to help us help you.
Hans Passant
2010-02-23 23:08:10
+2
A:
I believe that you can use the __nop intrinsic function. This should compile into the appropriate machine instruction for the processor that you are building.
http://msdn.microsoft.com/en-us/library/aa983381(VS.80).aspx
UPDATE:
Here is an example that I just created with VS2008. It compiles for both Win32 and x64 configurations:
#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;
}
In case you are wondering, I disassembled the above example and the x64 output was:
wmain proc near
db 66h
nop
nop
xor eax, eax
retn
wmain endp
The Win32 output was:
_main proc near
nop
xor eax, eax
retn
_main endp
Dustin
2010-02-23 19:53:32