CPUID: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
m →‎External Links: the link to AMD's documentation was dead
Max (talk | contribs)
m Added a note
Line 2: Line 2:


== How to use CPUID ==
== How to use CPUID ==
=== Checking CPUID availability ===
Prior to using the CPUID instruction, you should also make sure the processor supports it by testing the 'ID' bit (0x200000) in eflags. This bit is modifiable only when the CPUID instruction is supported. For systems that don't support CPUID, changing the 'ID' bit will have no effect.


'''Note:''' Implementing this routine in for example C can lead to issues, because the compiler may change EFLAGS at any time.
Note that prior to use the CPUID instruction, you should also make sure the processor supports it by testing the 'ID' bit (0x200000) in eflags (modifiable only when the CPUID instruction is supported. For systems that don't support CPUID, writing a '1' at that place will have no effect).

Here is an assembly routine that checks if CPUID is supported:
This assembly routine checks if CPUID is supported:


<source lang="asm">
<source lang="asm">
Line 24: Line 27:
</source>
</source>


=== Basic usage ===
The idea of the CPUID instruction is that you can call it with different values in EAX, and it will return different information about the processor. For example, if we want the Vendor ID String (see below), we should code something like that:
The idea of the CPUID instruction is that you can call it with different values in EAX, and it will return different information about the processor. For example, if we want the Vendor ID String (see below), we should code something like that: