CPUID
Encyclopedia
The CPUID opcode
Opcode
In computer science engineering, an opcode is the portion of a machine language instruction that specifies the operation to be performed. Their specification and format are laid out in the instruction set architecture of the processor in question...

 is a processor supplementary instruction (its name derived from CPU
Central processing unit
The central processing unit is the portion of a computer system that carries out the instructions of a computer program, to perform the basic arithmetical, logical, and input/output operations of the system. The CPU plays a role somewhat analogous to the brain in the computer. The term has been in...

 IDentification) for the x86 architecture. It was introduced by Intel in 1993 when it introduced the Pentium and SL-Enhanced 486 processors.

By using the CPUID opcode, software can determine processor type and the presence of features (like MMX/SSE
Streaming SIMD Extensions
In computing, Streaming SIMD Extensions is a SIMD instruction set extension to the x86 architecture, designed by Intel and introduced in 1999 in their Pentium III series processors as a reply to AMD's 3DNow! . SSE contains 70 new instructions, most of which work on single precision floating point...

). 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
Machine code
Machine code or machine language is a system of impartible instructions executed directly by a computer's central processing unit. Each instruction performs a very specific task, typically either an operation on a unit of data Machine code or machine language is a system of impartible instructions...

 which exploited minor differences in CPU behavior in order to determine the processor make and model. Outside the x86 family, developers are sometimes still required to use esoteric processes to determine the variations in CPU design are present. While the CPUID instruction is specific to the x86 architecture, other architectures often provide on-chip registers which can be read to obtain the same sorts of information provided by this instruction.

Calling CPUID

In assembly language
Assembly language
An assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other programmable devices. It implements a symbolic representation of the machine codes and other constants needed to program a given CPU architecture...

 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.

EAX=0: Get vendor ID

This returns the CPU's manufacturer ID string - a twelve character ASCII
ASCII
The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text...

 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:
  • "AMDisbetter!" - early engineering samples of AMD K5
    AMD K5
    The K5 was AMD's first x86 processor to be developed entirely in-house. Introduced in March 1996, its primary competition was Intel's Pentium microprocessor. The K5 was an ambitious design, closer to a Pentium Pro than a Pentium regarding technical solutions and internal architecture...

     processor
  • "AuthenticAMD" - AMD
    Advanced Micro Devices
    Advanced Micro Devices, Inc. or AMD is an American multinational semiconductor company based in Sunnyvale, California, that develops computer processors and related technologies for commercial and consumer markets...

  • "CentaurHauls" - Centaur
    Centaur Technology
    Centaur Technology is an x86 CPU design company, now a wholly owned subsidiary of VIA Technologies, a member of the Formosa Plastics Group, Taiwan's largest industrial conglomerate.-History:...

  • "CyrixInstead" - Cyrix
    Cyrix
    Cyrix Corporation was a microprocessor developer that was founded in 1988 in Richardson, Texas as a specialist supplier of high-performance math coprocessors for 286 and 386 microprocessors. The company was founded by former Texas Instruments staff members and had a long but troubled relationship...

  • "GenuineIntel" - Intel
    Intel Corporation
    Intel Corporation is an American multinational semiconductor chip maker corporation headquartered in Santa Clara, California, United States and the world's largest semiconductor chip maker, based on revenue. It is the inventor of the x86 series of microprocessors, the processors found in most...

  • "TransmetaCPU" - Transmeta
    Transmeta
    Transmeta Corporation was a US-based corporation that licensed low power semiconductor intellectual property. Transmeta originally produced very long instruction word code morphing microprocessors, with a focus on reducing power consumption in electronic devices. It was founded in 1995 by Bob...

  • "GenuineTMx86" - Transmeta
    Transmeta
    Transmeta Corporation was a US-based corporation that licensed low power semiconductor intellectual property. Transmeta originally produced very long instruction word code morphing microprocessors, with a focus on reducing power consumption in electronic devices. It was founded in 1995 by Bob...

  • "Geode by NSC" - National Semiconductor
    National Semiconductor
    National Semiconductor was an American semiconductor manufacturer, that specialized in analog devices and subsystems,formerly headquartered in Santa Clara, California, USA. The products of National Semiconductor included power management circuits, display drivers, audio and operational amplifiers,...

  • "NexGenDriven" - NexGen
    NexGen
    NexGen was a private semiconductor company that designed x86 microprocessors until it was purchased by AMD in 1996.Like competitor Cyrix, NexGen was a fabless design house that designed its chips but relied on other companies for production...

  • "RiseRiseRise" - Rise
    Rise Technology
    Rise Technology, was a short lived microprocessor manufacturer that produced the Intel x86 MMX compatible mP6 processor.The Santa Clara, California based company was started by David Lin in 1993 with funding from 15 Taiwanese investors, including UMC, ACER and VIA Technologies...

  • "SiS SiS SiS " - SiS
    Silicon Integrated Systems
    Silicon Integrated Systems is a company that manufactures, among other things, motherboard chipsets. The company was founded in 1987 in Hsinchu Science Park, Taiwan.-Business:...

  • "UMC UMC UMC " - UMC
    United Microelectronics Corporation
    UMC was founded as Taiwan's first semiconductor company in 1980 as a spin-off of the government-sponsored Industrial Technology Research Institute .-Overview:...

  • "VIA VIA VIA " - VIA
    VIA Technologies
    VIA Technologies is a Taiwanese manufacturer of integrated circuits, mainly motherboard chipsets, CPUs, and memory, and is part of the Formosa Plastics Group. It is the world's largest independent manufacturer of motherboard chipsets...

  • "Vortex86 SoC" - Vortex
    Vortex86
    The Vortex86 is a SoC based on an x86 compatible core. It formerly belonged to SiS, which got the basic design from Rise Technology, and was sold to the Taiwanese DM&P Electronics....


For instance, on a GenuineIntel processor values returned in EBX is 0x756e6547, EDX is 0x49656e69 and ECX is 0x6c65746e. The following code is written in GNU Assembler
GNU Assembler
The GNU Assembler, commonly known as GAS , is the assembler used by the GNU Project. It is the default back-end of GCC. It is used to assemble the GNU operating system and the Linux kernel, and various other software. It is a part of the GNU Binutils package.GAS' executable is named after as, a...

 for the x86-64
X86-64
x86-64 is an extension of the x86 instruction set. It supports vastly larger virtual and physical address spaces than are possible on x86, thereby allowing programmers to conveniently work with much larger data sets. x86-64 also provides 64-bit general purpose registers and numerous other...

 architecture and displays the vendor ID string as well as the highest calling parameter that the CPU supports.

.section .data
s0 : .asciz "Largest Standard Function Number Supported: %i\n"
s1 : .asciz "Vendor ID : %.12s\n"

.section .text

.global _start
.type _start,@function
.align 32
_start:
pushq %rbp
pushq %rbx
movq %rsp, %rbp
subq $16, %rsp

xorl %eax, %eax
cpuid

movl %ebx, (%rsp)
movl %edx, 4(%rsp)
movl %ecx, 8(%rsp)

movq $s0, %rdi
movl %eax, %esi
xorb %al, %al
call printf

movq $s1, %rdi
movq %rsp, %rsi
xorb %al, %al
call printf

movq %rbp, %rsp
popq %rbx
popq %rbp
movl $1, %eax
int $0x80

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 has 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.

AMD recommends the same only if "Family" is equal to 15 (i.e. all bits set to 1). If "Family" is lower than 15, only the "Family" and "Model" fields should be used while the "Extended Family" and "Extended Model" bits are reserved. If "Family" is set to 15, then "Extended Family" and the 4-bit left-shifted "Extended Model" should be added to the respective base values.

The processor info and feature flags are manufacturer specific but usually the Intel values are used by other manufacturers for the sake of compatibility.

The standard Intel feature flags are as follows
EAX=1 CPUID feature bits
Bit EDX ECX
Short Feature Short Feature
0 fpu Onboard x87
X87
x87 is a floating point-related subset of the x86 architecture instruction set. It originated as an extension of the 8086 instruction set in the form of optional floating point coprocessors that worked in tandem with corresponding x86 CPUs. These microchips had names ending in "87"...

 FPU
pni Prescott New Instructions (SSE3)
1 vme Virtual mode extensions (VIF) pclmulqdq PCLMULQDQ
CLMUL instruction set
Carry-less Multiplication is an extension to the x86 instruction set used by microprocessors from Intel and AMD which was proposed by Intel in March 2008 and made available in the Intel Westmere processors announced in early 2010. The purpose is to improve the speed of applications doing block...

 support
2 de Debugging extensions (CR4 bit 3) dtes64 64-bit debug store (edx bit 21)
3 pse Page size extensions  monitor MONITOR and MWAIT instructions (SSE3
SSE3
SSE3, Streaming SIMD Extensions 3, also known by its Intel code name Prescott New Instructions , is the third iteration of the SSE instruction set for the IA-32 architecture. Intel introduced SSE3 in early 2004 with the Prescott revision of their Pentium 4 CPU...

)
4 tsc Time Stamp Counter
Time Stamp Counter
The Time Stamp Counter is a 64-bit register present on all x86 processors since the Pentium. It counts the number of ticks since reset. The instruction "RDTSC" returns the TSC in EDX:EAX. In x86_64 mode, RDTSC also clears the higher 32 bits of RAX. Its opcode is 0F 31. Pentium competitors such as...

 
ds_cpl CPL qualified debug store
5 msr Model-specific register
Model-specific register
Model-specific registers are control registers provided by processor implementations to provide system software with features that are provided on specific processor implementations, but not others....

s
vmx Virtual Machine eXtensions
X86 virtualization
In computing, x86 virtualization is the facility that allows multiple operating systems to simultaneously share x86 processor resources in a safe and efficient manner, a facility generically known as hardware virtualization...

6 pae Physical Address Extension
Physical Address Extension
In computing, Physical Address Extension is a feature to allow x86 processors to access a physical address space larger than 4 gigabytes....

 
smx Safer Mode Extensions (LaGrande)
7 mce Machine Check Exception
Machine Check Exception
A Machine Check Exception is a type of computer hardware error that occurs when a computer's central processing unit detects a hardware problem....

 
est Enhanced SpeedStep
SpeedStep
SpeedStep is a trademark for a series of dynamic frequency scaling technologies built into some Intel microprocessors that allow the clock speed of the processor to be dynamically changed by software...

8 cx8 CMPXCHG8 (compare-and-swap
Compare-and-swap
In computer science, the compare-and-swap CPU instruction is a special instruction that atomically compares the contents of a memory location to a given value and, only if they are the same, modifies the contents of that memory location to a given new value...

) instruction
tm2 Thermal Monitor 2
Tm2
TM2, or "Thermal Monitoring 2", is a throttling control method used on LGA 775 versions of the Pentium 4, Pentium D and Celeron processors and also on the Pentium M series of processors. TM2 reduces processor temperature by lowering the CPU clock multiplier, and thereby the processor core speed...

9 apic Onboard Advanced Programmable Interrupt Controller
Advanced Programmable Interrupt Controller
In computing, an Advanced Programmable Interrupt Controller is a more complex Programmable Interrupt Controller than Intel's original types such as the 8259A...

 
ssse3 Suplemental SSE3
SSSE3
Supplemental Streaming SIMD Extensions 3 is a SIMD instruction set created by Intel and is the fourth iteration of the SSE technology.- History :...

 instructions
10 (reserved) cid Context ID
11 sep SYSENTER and SYSEXIT instructions (reserved)
12 mtrr Memory Type Range Registers
Memory Type Range Registers
Memory type range registers are a set of processor supplementary capabilities control registers that provide system software with control of how accesses to memory ranges by the CPU are cached...

 
fma Fused multiply-add
FMA instruction set
The FMA instruction set is the name of a future extension to the 128-bit SIMD instructions in the X86 microprocessor instruction set to perform fused multiply–add operations...

 (FMA3)
13 pge Page Global Enable bit in CR4  cx16 CMPXCHG16B instruction
14 mca Machine check architecture
Machine check architecture
In computing, Machine Check Architecture refers to a mechanism in which the CPU reports hardware errors to the operating system.Intel's Pentium 4, Intel Xeon, P6 family processors as well as the Itanium architecture implement a machine check architecture that provides a mechanism for detecting and...

 
xtpr Can disable sending task priority messages
15 cmov Conditional move and FCMOV
FCMOV
FCMOV is a floating point conditional move opcode of the Intel x86 architecture, first introduced in Pentium Pro processors. It copies the contents of one of the floating point stack register, depending on the contents of EFLAGS integer flag register, to the ST register...

 instructions
pdcm Perfmon & debug capability
16 pat Page Attribute Table
Page Attribute Table
The page attribute table is a processor supplementary capability extension to the page table format of certain x86 and x86-64 microprocessors...

 
(reserved)
17 pse36 36-bit page huge pages pcid Process context identifiers (CR4 bit 17)
18 pn Processor Serial Number  dca Direct cache access for DMA writes
19 clflush CLFLUSH instruction (SSE2
SSE2
SSE2, Streaming SIMD Extensions 2, is one of the Intel SIMD processor supplementary instruction sets first introduced by Intel with the initial version of the Pentium 4 in 2001. It extends the earlier SSE instruction set, and is intended to fully supplant MMX. Intel extended SSE2 to create SSE3...

)
sse4_1 SSE4.1 instructions
20 (reserved) sse4_2 SSE4.2 instructions
21 dts Debug store: save trace of executed jumps x2apic x2APIC
X2APIC
The x2APIC architecture provides backward compatibility to the Intel APIC Architecture/xAPIC architecture and forward extendability for future Intel platform innovations.-More information:...

 support
22 acpi Onboard thermal control MSRs for ACPI
Advanced Configuration and Power Interface
In computing, the Advanced Configuration and Power Interface specification provides an open standard for device configuration and power management by the operating system....

 
movbe MOVBE instruction (big-endian, Intel Atom
Intel Atom
Intel Atom is the brand name for a line of ultra-low-voltage x86 and x86-64 CPUs from Intel, designed in 45 nm CMOS and used mainly in netbooks, nettops, embedded application ranging from health care to advanced robotics and Mobile Internet devices...

 only)
23 mmx MMX instructions popcnt POPCNT
Population count
Population count may refer to:* A census, the process of obtaining information about every member of a population...

 instruction
24 fxsr FXSAVE, FXRESTOR instructions, CR4 bit 9 tscdeadline APIC supports one-shot operation using a TSC deadline value
25 sse SSE
Streaming SIMD Extensions
In computing, Streaming SIMD Extensions is a SIMD instruction set extension to the x86 architecture, designed by Intel and introduced in 1999 in their Pentium III series processors as a reply to AMD's 3DNow! . SSE contains 70 new instructions, most of which work on single precision floating point...

 instructions (a.k.a. Katmai New Instructions)
aes AES instruction set
AES instruction set
Advanced Encryption Standard Instruction Set is an extension to the x86 instruction set architecture for microprocessors from Intel and AMD proposed by Intel in March 2008...

26 sse2 SSE2
SSE2
SSE2, Streaming SIMD Extensions 2, is one of the Intel SIMD processor supplementary instruction sets first introduced by Intel with the initial version of the Pentium 4 in 2001. It extends the earlier SSE instruction set, and is intended to fully supplant MMX. Intel extended SSE2 to create SSE3...

 instructions
xsave XSAVE, XRESTOR, XSETBV, XGETBV
27 ss CPU cache supports self-snoop  osxsave XSAVE enabled by OS
28 ht Hyper-threading
Hyper-threading
Hyper-threading is Intel's term for its simultaneous multithreading implementation in its Atom, Intel Core i3/i5/i7, Itanium, Pentium 4 and Xeon CPUs....

 
avx Advanced Vector Extensions
Advanced Vector Extensions
Advanced Vector Extensions is an extension to the x86 instruction set architecture for microprocessors from Intel and AMD proposed by Intel in March 2008 and first supported by Intel with the Westmere processor shipping in Q1 2011 and now by AMD with the Bulldozer processor shipping in Q3 2011.AVX...

29 tm Thermal monitor automatically limits temperature f16c CVT16 instruction set
CVT16 instruction set
The CVT16 instruction set, announced by AMD on May 1, 2009, is an extension to the 128-bit SSE core instructions in the x86 and AMD64 instruction set.CVT16 is a revision of part of the SSE5 instruction set proposal announced on August 30, 2007...

 (half-precision) FP support
30 ia64 IA64 processor emulating x86 rdrnd RDRAND
RdRand
RdRand is an instruction for returning random numbers from an on-chip random number generator that will be available in Ivy Bridge processors. It is part of the Intel 64 instruction set architecture...

 (on-chip random number generator) support
31 pbe Pending Break Enable (PBE# pin) wakeup support hypervisor Running on a hypervisor
Hypervisor
In computing, a hypervisor, also called virtual machine manager , is one of many hardware virtualization techniques that allow multiple operating systems, termed guests, to run concurrently on a host computer. It is so named because it is conceptually one level higher than a supervisory program...

 (always 0 on a real CPU)

EAX=2: Cache and TLB Descriptor information

This returns a list of descriptors indicating cache and TLB
Translation Lookaside Buffer
A translation lookaside buffer is a CPU cache that memory management hardware uses to improve virtual address translation speed. All current desktop and server processors use a TLB to map virtual and physical address spaces, and it is ubiquitous in any hardware which utilizes virtual memory.The...

 capabilities in EAX, EBX, ECX and EDX registers.

EAX=3: Processor Serial Number

This returns the processor's serial number. The processor serial number was introduced on Intel Pentium III
Pentium III
The Pentium III brand refers to Intel's 32-bit x86 desktop and mobile microprocessors based on the sixth-generation P6 microarchitecture introduced on February 26, 1999. The brand's initial processors were very similar to the earlier Pentium II-branded microprocessors...

, but due to privacy concerns, this feature is no longer implemented on later models (PSN feature bit is always cleared). Transmeta's
Transmeta
Transmeta Corporation was a US-based corporation that licensed low power semiconductor intellectual property. Transmeta originally produced very long instruction word code morphing microprocessors, with a focus on reducing power consumption in electronic devices. It was founded in 1995 by Bob...

 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
BIOS
In IBM PC compatible computers, the basic input/output system , also known as the System BIOS or ROM BIOS , is a de facto standard defining a firmware interface....

 setting in order to function.

EAX=80000000h: Get Highest Extended Function Supported

The highest calling parameter is returned in EAX.

EAX=80000001h: Extended Processor Info and Feature Bits

This returns extended feature flags in EDX and ECX.

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. It is necessary to check whether the feature is supported by the CPU by issuing CPUID with EAX = 80000000h first and checking if the returned value is greater or equal to 80000004h.

.section .data

s0 : .asciz "Processor Brand String: %.48s\n"
err : .asciz "Feature unsupported.\n"

.section .text

.global main
.type main,@function
.align 32
main:
pushq %rbp
movq %rsp, %rbp
subq $48, %rsp
pushq %rbx

movl $0x80000000, %eax
cpuid

cmpl $0x80000004, %eax
jl error

movl $0x80000002, %esi
movq %rsp, %rdi

.align 16
get_brand:
movl %esi, %eax
cpuid

movl %eax, (%rdi)
movl %ebx, 4(%rdi)
movl %ecx, 8(%rdi)
movl %edx, 12(%rdi)

addl $1, %esi
addq $16, %rdi
cmpl $0x80000004, %esi
jle get_brand

print_brand:
movq $s0, %rdi
movq %rsp, %rsi
xorb %al, %al
call printf

jmp end

.align 16
error:
movq $err, %rdi
xorb %al, %al
call printf

.align 16
end:
popq %rbx
movq %rbp, %rsp
popq %rbp
xorl %eax, %eax
ret

EAX=80000005h: L1 Cache and TLB Identifiers

This function contains the processor’s L1 cache and TLB characteristics.

EAX=80000006h: Extended L2 Cache Features

Returns details of the L2 cache in ECX, including the line size in bytes, type of associativity (encoded by a 4 bits) and the cache size.

.section .data

info : .ascii "L2 Cache Size : %u KB\nLine size : %u bytes\n"
.asciz "Associativity : %02xh\n"
err : .asciz "Feature unsupported.\n"

.section .text

.global main
.type main,@function
.align 32
main:
pushq %rbp
movq %rsp, %rbp
pushq %rbx

movl $0x80000000, %eax
cpuid

cmpl $0x80000006, %eax
jl error

movl $0x80000006, %eax
cpuid

movl %ecx, %eax

movl %eax, %edx
andl $0xff, %edx

movl %eax, %ecx
shrl $12, %ecx
andl $0xf, %ecx

movl %eax, %esi
shrl $16, %esi
andl $0xffff,%esi

movq $info, %rdi
xorb %al, %al
call printf

jmp end

.align 16
error:
movq $err, %rdi
xorb %al, %al
call printf

.align 16
end:
popq %rbx
movq %rbp, %rsp
popq %rbp
xorl %eax, %eax
ret

EAX=80000007h: Advanced Power Management Information

This function provides advanced power management feature identifiers.

EAX=80000008h: Virtual and Physical address Sizes

Returns largest virtual and physical address sizes in EAX.

Accessing the id from other languages

This information is easy to access from other languages as well. For instance, the C++ code for gcc below prints the first five values, returned by the cpuid:
  1. include


int main
{
int a, b;

for (a = 0; a < 5; a++)
{
__asm ( "mov %1, %%eax; " // a into eax
"cpuid;"
"mov %%eax, %0;" // eax into b
:"=r"(b) // output
:"r"(a) // input
:"%eax","%ebx","%ecx","%edx" // clobbered register
);
std::cout << "The code " << a << " gives " << b << std::endl;
}

return 0;
}


In C, the code may be shortened to:


int main
{
int a, b;

for (a = 0; a < 5; a++)
{
__asm( "cpuid"
: "=a" (b) // EAX into b (output)
: "a" (a) // a into EAX (input)
:"%ebx","%ecx","%edx"); // cpuid always clobbers these

printf("The code %i gives %i\n", a, b);
}

return 0;
}


Or, a generally useful C implementation that works on 32 and 64 bit setups:

  1. include


void cpuid(unsigned info, unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx)
{
*eax = info;
__asm volatile
("mov %%ebx, %%edi;" /* 32bit PIC: don't clobber ebx */
"cpuid;"
"mov %%ebx, %%esi;"
"mov %%edi, %%ebx;"
:"+a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx)
: :"edi");
}

int main
{
unsigned int eax, ebx, ecx, edx;
int i;

for (i = 0; i < 6; ++i)
{
cpuid(i, &eax, &ebx, &ecx, &edx);
printf("eax=%i: %#010x %#010x %#010x %#010x\n", i, eax, ebx, ecx, edx);
}

return 0;
}


Microsoft Visual C compiler has builtin function __cpuid so cpuid instruction may be embedded without using inline assembly. This is handy since x64 version of MSVC doesn't allow inline assembly at all. The same program for MSVC would be:
  1. include
  2. include


int main
{
int b[4];

for (int a = 0; a < 5; a++)
{
__cpuid(b,a);
std::cout << "The code " << a << " gives " << b[0] << std::endl;
}

return 0;
}


For Borland/Embarcadero C compilers (bcc32), native asm function calls are necessary, as there is no asm implementation. The pseudo code:

unsigned int a, b, c, d;
unsigned int InfoType = 0;
__asm xor EBX, EBX;
__asm xor ECX, ECX;
__asm xor EDX, EDX;
__asm mov EAX, InfoType;
__asm cpuid;
__asm mov a, EAX;
__asm mov b, EBX;
__asm mov c, ECX;
__asm mov d, EDX;

Uptake of CPUID instructions outside x86

The Intel-AMD x86 family has so far been the only CPU family to have a CPUID instruction. RISC, DSP and transputer like chip families have not taken up the instruction in any noticeable way, in spite of having (in relative terms) as many variations in design.

See also

  • Pentium III: Controversy about privacy issues.
  • CPU-Z
    CPU-Z
    CPU-Z is a freeware system profiler application for Microsoft Windows that detects the central processing unit, RAM, motherboard chipset, and other hardware features of a modern personal computer, and presents the information in one window.CPU-Z is more in-depth in almost all areas than the tools...

    , a Windows utility that uses CPUID to identify various system settings.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK