CPUID
From Wikipedia, the free encyclopedia
The CPUID opcode is an instruction (its name derived from CPU IDentification) for the x86 architecture. It was introduced by Intel in the early 1990s for later steppings of the 486 chip, and fully rolled out at the introduction of the Pentium processor.[1]
By using the CPUID opcode, software can determine processor type and the presence of features (like MMX/SSE). The CPUID opcode is 0FA2h and the value in the EAX register specifies what information to return.
Prior to the general availability of the CPUID instruction, programmers would write esoteric machine code which exploited minor differences in CPU behavior in order to determine the processor make and model.[2][3]
[edit] Calling CPUID
In assembly language the CPUID instruction takes no parameters as CPUID implicitly uses the EAX register. The EAX register should be loaded with a value specifying what information to return. CPUID should be called with EAX = 0
first, as this will return the highest calling parameter that the CPU supports. To obtain extended function information CPUID should be called with bit 31 of EAX set. To determine the highest extended function calling parameter, call CPUID with EAX = 80000000h
.
[edit] EAX=0: Get vendor ID
This returns the CPU's manufacturer ID string - a twelve character ASCII string stored in EBX, EDX, ECX - in that order. The highest basic calling parameter is returned in EAX.
The following are known processor manufacturer ID strings:
- "GenuineIntel" - Intel
- "AuthenticAMD" - AMD
- "CyrixInstead" - Cyrix
- "CentaurHauls" - Centaur
- "SiS SiS SiS " - SiS
- "NexGenDriven" - NexGen
- "GenuineTMx86", "TransmetaCPU" - Transmeta
- "RiseRiseRise" - Rise
- "UMC UMC UMC " - UMC
- "Geode by NSC" - National Semiconductor
- "AMDisbetter!" - early engineering samples of AMD K5 processor
For instance, on a GenuineIntel processor values returned in EBX is 0x756e6547, EDX is 0x49656e69 and ECX is 0x6c65746e.
[edit] EAX=1: Processor Info and Feature Bits
This returns the CPU's stepping, model, and family information in EAX (also called the signature of a CPU), feature flags in EDX and ECX, and additional feature info in EBX.
The format of the information in EAX is as follows:
- 3:0 - Stepping
- 7:4 - Model
- 11:8 - Family
- 13:12 - Processor Type
- 19:16 - Extended Model
- 27:20 - Extended Family
Intel and AMD have suggested applications to display the family of a CPU as the sum of the "Family" and the "Extended Family" fields shown above, and the model as the sum of the "Model" and the 4-bit left-shifted "Extended Model" fields shown above.
The processor info and feature flags are manufacturer specific but usually the Intel values are used by other manufacturers for the sake of compatibility.
[edit] EAX=2: Cache and TLB Descriptor Info
This returns a list of descriptors indicating cache and TLB capabilities in EAX, EBX, ECX and EDX registers.
[edit] EAX=3: Processor Serial Number
This returns the processor's serial number. The processor serial number was introduced on Intel Pentium III, but due to privacy concern, this feature is no longer implemented on later models (PSN feature bit is always cleared). Transmeta's Efficeon and Crusoe processors also provide this feature. AMD CPUs however, do not implement this feature in any CPU models.
For Intel Pentium III CPUs, the serial number is returned in EDX:ECX registers. For Transmeta Efficeon CPUs, it is returned in EBX:EAX registers. And for Transmeta Crusoe CPUs, it is returned in EBX register only.
Note that the processor serial number feature must be enabled in the BIOS setting in order to function.
[edit] EAX=80000000h: Get Highest Extended Function Supported
The highest calling parameter is returned in EAX.
[edit] EAX=80000001h: Extended Processor Info and Feature Bits
This returns extended feature flags in EDX and ECX.
[edit] EAX=80000002h,80000003h,80000004h: Processor Brand String
These return the processor brand string in EAX, EBX, ECX and EDX. CPUID must be issued with each parameter in sequence to get the entire 48-byte null-terminated ASCII processor brand string.
[edit] See also
- Pentium III: Controversy about privacy issues.
- CPU-Z, a Windows utility that uses CPUID to identify various system settings.
[edit] External links
- http://www.sandpile.org/ia32/cpuid.htm
- http://www.sandpile.org/ -- Technical x86 processors information
- CPUID guide:
- Windows programs:
- Linux programs:
- http://www.etallen.com/cpuid.html
- http://www.ka9q.net/code/cpuid/
- the /proc/cpuinfo interface which among other information shows most of the cpuid output
- Solaris provides the /dev/cpu/self/cpuid interface