Use the cpuid Assembly command (machine code: 0fh a2h, if your compiler does not support cpuid command, only emit machine code), this command can be recognized by the following CPU:
More than 486 of Intel CPUs,
CPU above cyrix M1,
CPU above amd am486
(1) obtain the cpu oem string to determine the CPU vendor
Let eax = 0 first, then call cpuid
InEl CPU will return:
EBX: 756e6547h 'genu' EdX: 49656e69h 'inei' ECX: 6c65746eh 'ntel' EBX, EDX, and ECX will be connected to genuineintel. |
The CPU of cyrix will return:
EBX: 43797269 H EdX: 78496e73h ECX: 74656164 H "Cyrixinstead", "cyrix to replace ". |
Amd cpu will return:
EBX: 41757468 H EdX: 656e7469h ECX: 63414d44h "Authenticamd", trusted AMD. |
In Windows 98, right-click "my computer" and choose "properties-General" to view the cpu oem string in the computer description.
(2) Check whether MMX is supported for 86 CPUs.
First let eax = 1 and then call cpuid
The 8 to 11 bits of eax indicate the number of 86
3-386
4-iworkflow
5-Pentium
6-Pentium Pro Pentium II
2-dual processors
0th-bit edX: FPU or not
23rd-bit edX: whether the CPU supports Ia MMX is very important! If you want to use the 57 new commands, check this digit first. Otherwise, you will wait for Windows to see "The program has executed illegal commands and will be shut down.
(3) dedicated detection of P6 Architecture
First let eax = 1 and then call cpuid
If Al = 1, it is Pentium Pro or Pentium II.
(4) dedicated detection of amd cpu Information
First let eax = 80000001 h and then call cpuid
If eax = 51 H, It is amd K5
If eax = 66 h, It is K6
0th-bit edX: whether FPU exists (redundant! Who used K5 and K6 without FPU ?)
23rd-bit edX, CPU support for MMX,
The procedure is as follows:
// ------ Cpuid instruction demo program ------------ # Include # Include # Pragma hdrstop //------------------------------------------------ # Pragma inline # Pragma argsused Int main (INT argc, char ** argv) { Char oemstring [13]; Int ieaxvalue, iebxvalue, iecxvalue, iedxvalue; _ ASM { MoV eax, 0 Cpuid MoV dword ptr oemstring, EBX MoV dword ptr oemstring 4, EDX MoV dword ptr oemstring 8, ECx MoV byte PTR oemstring 12, 0 } Cout <"This CPU's OEM string is:" <oemstring <Endl; _ ASM { MoV eax, 1 Cpuid MoV ieaxvalue, eax MoV iebxvalue, EBX MoV iecxvalue, ECx MoV iedxvalue, EDX } If (iedxvalue & 0 x800000) Cout <"this is mmx cpu" <Endl; Else Cout <"None MMX support." <Endl; Int icpufamily = (0xf00 & ieaxvalue)> 8; Cout <"CPU family is:" <icpufamily <Endl; _ ASM { MoV eax, 2 Cpuid } If (_ Al = 1) Cout <"Pentium Pro or Pentium II found "; Getch (); Return 0; } |
Use the cpuid Assembly command (machine code: 0fh a2h, if your compiler does not support cpuid command, only emit machine code), this command can be recognized by the following CPU:
More than 486 of Intel CPUs,
CPU above cyrix M1,
CPU above amd am486
(1) obtain the cpu oem string to determine the CPU vendor
Let eax = 0 first, then call cpuid
InEl CPU will return:
EBX: 756e6547h 'genu' EdX: 49656e69h 'inei' ECX: 6c65746eh 'ntel' EBX, EDX, and ECX will be connected to genuineintel. |
The CPU of cyrix will return:
EBX: 43797269 H EdX: 78496e73h ECX: 74656164 H "Cyrixinstead", "cyrix to replace ". |
Amd cpu will return:
EBX: 41757468 H EdX: 656e7469h ECX: 63414d44h "Authenticamd", trusted AMD. |
In Windows 98, right-click "my computer" and choose "properties-General" to view the cpu oem string in the computer description.
(2) Check whether MMX is supported for 86 CPUs.
First let eax = 1 and then call cpuid
The 8 to 11 bits of eax indicate the number of 86
3-386
4-iworkflow
5-Pentium
6-Pentium Pro Pentium II
2-dual processors
0th-bit edX: FPU or not
23rd-bit edX: whether the CPU supports Ia MMX is very important! If you want to use the 57 new commands, check this digit first. Otherwise, you will wait for Windows to see "The program has executed illegal commands and will be shut down.
(3) dedicated detection of P6 Architecture
First let eax = 1 and then call cpuid
If Al = 1, it is Pentium Pro or Pentium II.
(4) dedicated detection of amd cpu Information
First let eax = 80000001 h and then call cpuid
If eax = 51 H, It is amd K5
If eax = 66 h, It is K6
0th-bit edX: whether FPU exists (redundant! Who used K5 and K6 without FPU ?)
23rd-bit edX, CPU support for MMX,
The procedure is as follows:
// ------ Cpuid instruction demo program ------------ # Include # Include # Pragma hdrstop //------------------------------------------------ # Pragma inline # Pragma argsused Int main (INT argc, char ** argv) { Char oemstring [13]; Int ieaxvalue, iebxvalue, iecxvalue, iedxvalue; _ ASM { MoV eax, 0 Cpuid MoV dword ptr oemstring, EBX MoV dword ptr oemstring 4, EDX MoV dword ptr oemstring 8, ECx MoV byte PTR oemstring 12, 0 } Cout <"This CPU's OEM string is:" <oemstring <Endl; _ ASM { MoV eax, 1 Cpuid MoV ieaxvalue, eax MoV iebxvalue, EBX MoV iecxvalue, ECx MoV iedxvalue, EDX } If (iedxvalue & 0 x800000) Cout <"this is mmx cpu" <Endl; Else Cout <"None MMX support." <Endl; Int icpufamily = (0xf00 & ieaxvalue)> 8; Cout <"CPU family is:" <icpufamily <Endl; _ ASM { MoV eax, 2 Cpuid } If (_ Al = 1) Cout <"Pentium Pro or Pentium II found "; Getch (); Return 0; } |