How to Find out if the CPU Supports the CPUID Instruction

Sometimes you may want to find out if the CPU supports the CPUID instruction (late 486+ or Pentium+) to find out the CPU type. Well, this code should be what you need:
<pre>
<i>{$ifndef ver80} // Because of 32 bit register use</i>
<b>function</b> GetCpuIDSupport: Boolean; <b>assembler</b>;
<b>asm</b>
push ebx
mov @Result, True
pushfd <i>// Save EFLAGS</i>
pop eax <i>// Store EFLAGS in EAX</i>
mov ecx, eax <i>// Save in ECX for later testing</i>
xor eax, $00200000 <i>// Toggle bit 21 in EFLAGS</i>
push eax
popfd <i>// Save changed EAX to EFLAGS</i>
pushfd <i>// Push EFLAGS to TOS</i>
pop eax <i>// Store EFLAGS in EAX</i>
xor eax, ecx <i>// Check if bit 21 has</i> changed
jnz @Exit <i>// If no changes has been made the CPUID is not supported</i>
mov @Result, False
@EXIT:
pop ebx
<b>end</b>;
<i>{$endif}</i>
</pre>

Tags: , , , , , , , , , , , , , , ,

No Comments Yet

You can be the first to comment!

Leave a comment

OpenID Login

Standard Login