Use the program to get CPU information

zhaozj2021-02-08  221

---- Multi-software can be self-reliating different processing in judging the type of computer that is running. For example, Photoshop 5 can detect whether the CPU has a MMX support and a different processing function. The "Golden Mountain Words" issued an existing MMX support to produce a semi-translated translation report, and many software can be distinguished by INTEL, CYRIX, AMD CPU ...

---- Now, let me make a thin way to get the CPU information in your own program.

---- The main can be used in the CPUID compilation (machine code: 0FH A2H, if your compiler does not support the CPUID instruction, only the EMIT machine code) This instruction can be used as a CPU

Intel 486 CPU above,

CPU above Cyrix M1,

CPU above AMD AM486

(1) Take the CPU OEM string, sentenced the CPU factory

Let EAX = 0 first, then call CPUID

Inel's CPU will return:

EBX: 756E6547H 'Genu'

EDX: 49656E69H 'INEI'

ECX: 6C65746EH 'ntel'

EBX, EDX, ECX will be "Genuineintel", true Intel.

Cyrix's CPU will return:

EBX: 43797269H

EDX: 78496E73H

ECX: 74656164H

"Cyrixinstead", "Cyrix is ​​replaced".

AMD's CPU will return:

EBX: 41757468H

EDX: 656E7469H

ECX: 63414D44H

"Authenticamd", trusted AMD.

---- In Windows98, use the right to click "My Computer", select "Properties - General" to see the CPU OEM string in the calculation program.

(2) CPU to the bottom is a few 86, is it supported by MMX?

Let Eax = 1 first, then call CPUID

EAX's 8 to 11 tables is a few 86

3 - 386

4 - i486

5 - Pentium

6 - Pentium Pro Pentium II

2 - Dual Processors

EDX 0 digits: no fpu

EDX 23rd: CPU is expensive to hold IA MMX, very important! If you want to use the 57 new instructions, check this one, and wait for the "The process of the" the program to be closed ".

(3) Special inspection Yes No P6

Let Eax = 1 first, then call CPUID

If Al = 1 is Pentium Pro or Pentium II

(4) Specialize detecting AMD CPU information

Let EAX = 80000001H, then call CPUID

If eax = 51h is AMD K5

If eax = 66h is K6

EDX 0th: Yes No FPU

EDX 23rd, the CPU is supported by MMX,

The procedure is as follows: It is the control station of C Builder to give your "heart" information. If this technique is used in DLL, you can know the "heart" information in the DLL. // ------ 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

_asm {

MOV Eax, 1

cpuid

Mov IEAXVALUE, EAX

MOV IEBXVALUE, EBX

MOV IECxValue, ECX

MOV IEDXVALUE, EDX

}

Ie (IEDXVALUE & 0x800000)

COUT

Else

COUT <"None MMX Support."

INT ICPUFAMILY = (0xF00 & IEaxValue)>> 8;

COUT <"CPU Family IS:"

_asm {

MOV Eax, 2

Cpuid

}

IF (_al == 1)

COUT <"Pentium Pro or Pentium II Found";

Getch ();

Return 0;

}

转载请注明原文地址:https://www.9cbs.com/read-3211.html

New Post(0)