I have a small class for getting CpuID information. Inside a class constructor I have an inline function using asm code to get cpuid information. It works fine in Windows and it worked fine in Xcode 3, but now the class itself gets destroyed.
Here is the function beginning:
inline void CCPUDetector::_DetectCPU()
{
char lvendor[13] = "UnknownVendr";
unsigned int lfamily;
unsigned int lmodel;
unsigned int lstepping;
unsigned int lfeatures = 0;
unsigned int lBasicInfo = 0;
uint32_t cpu_cores = 0;
uint32_t cpu_count = 1;
unsigned int signature = 0;
// Step 1: check if a processor supports CPUID instruction
// ============================================================
try
{
__asm
{
// Reset all registers
xor eax, eax
xor ebx, ebx
xor ecx, ecx
xor edx, edx
// Call CPUID with eax register == 0
cpuid
};
}
// Old processors that do not support cpuid will throw exception
// which is caught in the command below "__except"
catch(...)
{
return;
}
}
After the __asm block the CPUDetector class itself, the one that I am in it's constructor become invalid (NULL). I tried to disable different Xor's or cpuid but I got the same results every time.
Can someone suggest what am I doing wrong?