/*
* 用汇编获得CPU信息
eax=0 调用cpuid
ebx,edx,ecx 返回cpu的oem信息
eax=0 调用cpuid
eax 的8--11位表明是几86
3--------386
4--------486
5--------Pentium
6--------Pentium pro Pentium II
2--------Dual Processors
检测是否是p6购架
eax=1 cpuid
如果al=1,是Pentium pro Pentium II
amd cpu
eax = 80000001 cpuid
---------------------
eax=51h AMD k5
eax =66h k6
*/
#include<iostream>
#include<conio.h>
#pragma hdrstop
//#pragma inline
//#pragma argsused
using namespace std;
int main()
{
char OemStr[13];
int eaxValue,ebxValue,ecxValue,edxValue;
_asm
{
mov eax,0
cpuid
mov DWORD PTR OemStr,ebx
mov DWORD PTR OemStr+4,edx
mov DWORD PTR OemStr+8,ecx
mov BYTE PTR OemStr+12,0
}
cout<<"This cpu's OEM string is: "<<OemStr<<endl;
_asm
{
mov eax,1
cpuid
mov eaxValue,eax
mov ebxValue,ebx
mov ecxValue,ecx
mov edxValue,edx
}
if(edxValue & 0x800000 )
{
cout<<"This is MMX CPU"<<endl;
}
else
{
cout<<"Not MMX Support"<<endl;
}
int cpuFamily =(0xf00 & eaxValue) >>8;
cout<<"CPU Family is:"<<cpuFamily<<endl;
int alvalue;
_asm
{
mov eax,2
CPUID
mov byte ptr alvalue,al
}
if(alvalue==1)
{
cout<<"Pentium pro or Pentium II Found"<<endl;
}
getch();
return 0;
}