Intel 64 and IA-32 Architectures Software Developers Manual Volume 1, Basic Architecture

Vol. 1 14-1
CHAPTER 14
PROCESSOR IDENTIFICATION AND
FEATURE DETERMINATION
When writing software intended to run on IA-32 processors, it is necessary to identify
the type of processor present in a system and the processor features that are avail-
able to an application.
14.1 USING THE CPUID INSTRUCTION
Use the CPUID instruction for processor identification in the Pentium M processor
family, Pentium 4 processor family, Intel Xeon processor family, P6 family, Pentium
processor, and later Intel486 processors. This instruction returns the family, model
and (for some processors) a brand string for the processor that executes the instruc-
tion. It also indicates the features that are present in the processor and give informa-
tion about the processors caches and TLB.
The ID flag (bit 21) in the EFLAGS register indicates support for the CPUID instruc-
tion. If a software procedure can set and clear this flag, the processor executing the
procedure supports the CPUID instruction. The CPUID instruction will cause the
invalid opcode exception (#UD) if executed on a processor that does not support it.
To obtain processor identification information, a source operand value is placed in the
EAX register to select the type of information to be returned. When the CPUID
instruction is executed, selected information is returned in the EAX, EBX, ECX, and
EDX registers. For a complete description of the CPUID instruction, tables indicating
values returned, and example code, see “CPUID—CPUID Identification” in Chapter 3
of the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 2A.
14.1.1 Notes on Where to Start
For detailed application notes on the instruction, see AP-485, Intel Processor Identi-
fication and the CPUID Instruction (Order Number 241618). This publication provides
additional information and example source code for use in identifying IA-32 proces-
sors. It also contains guidelines for using the CPUID instruction to help maintain the
widest range of software compatibility. The following guidelines are among the most
important, and should always be followed when using the CPUID instruction to deter-
mine available features:
Always begin by testing for the “GenuineIntel,” message in the EBX, EDX, and
ECX registers when the CPUID instruction is executed with EAX equal to 0. If the
processor is not genuine Intel, the feature identification flags may have different
meanings than are described in Intel documentation.