Click to See Complete Forum and Search --> : Problem to detect K6 in VC++. Please Help!!!


Yuheng Zhao
April 17th, 1999, 02:59 AM
I use this code from www.amd.com to detect if the user is using K6 or later. However, VC++ 6.0 refuses to compile this line
db 0fh, 0a2h
and the error message is
"error C2400: inline assembler syntax error in 'opcode'; found 'constant'"

I know nothing about assembler, so I appreciate any help I can get.

Thanks a lot!

The code is:


unsigned long family=0;
unsigned long model_no=0;
unsigned long stepping=0;

unsigned long mode1=0, mode2=0, mode3=0;
unsigned long save_value;

_asm{
// cpu_oK - run CPUID instruction to get cpu vendor
mov eax, 0 // function 0
db 0fh, 0a2h // CPUID opcode
mov mode1, ebx // load to string variable
mov mode2, edx // load to string variable
mov mode3, ecx // load to string variable
}

if ((mode1 == htuA) && (mode2 == itne) && (mode3 == DMAc)) // AMD CPU
{
_asm {
mov eax, 1 // function 1
db 0fh, 0a2h // CPUID opcode
mov save_value, eax // reload the whole cpu family
}

family = (save_value >> 8) & 0x0F; // find out the familu number (8 - 11 bits in EAX register)

model_no = (save_value >> 4) & 0x0F; // find out the model number (4 - 7 bits in EAX register)

stepping = save_value & 0x0F; // find out the stepping number (0 - 3 bits in EAX register)

}

if (family == 5)
{
if (model_no < 6) // K5
return false;
else // K6
return true;
}
}




if (family>5) // K7 or later
return true;