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

Thành Viên Mới
14th May 2011, 17: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;
mov eax, 80000001h
mov CPU_ID, edx
return CPU_ID;

14th May 2011, 18: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, 19:25
i run source code on Qt ( mingw32) on windows 7, Fail to compile beacause mingw dont understand asm inline as VC++

14th May 2011, 19: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

14th May 2011, 19: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.