PDA

View Full Version : how to convert inline asm from VC++ to gcc ( Qt creator )



Thành Viên Mới
14th May 2011, 16:22
i code to get CPU ID by VC++, but when i paste it to Qtcreator then it cant run, can you help me convert it , thanks


//_____________________
unsigned long getCPUID()
{
unsigned long CPU_ID;
__asm
{
mov eax, 80000001h
CPUID
mov CPU_ID, edx
};
return CPU_ID;
}

SixDegrees
14th May 2011, 17:44
"It can't run" isn't very helpful. What, exactly, does it not do? Fail to compile? Fail to produce output when run? Crash? What, if any, error messages are produced? What system and compiler are you using?

Thành Viên Mới
14th May 2011, 18:25
i run source code on Qt ( mingw32) on windows 7, Fail to compile beacause mingw dont understand asm inline as VC++

squidge
14th May 2011, 18:25
What steps did you follow to try and port the code yourself? Did you read the GCC inline assembly howto? http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html

SixDegrees
14th May 2011, 18:43
More to the point, read this (http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html#s4). You can't expect a different compiler to recognize compiler-specific constructs used by another compiler.