I want to detect CPUs (386,486,Pentium,Pentium MMX,Pentium Pro, Pentium II/III/IV).

I found Agner's code that detect MMX and P-II.
But It cannot detect 386,486
(It uses 'CPUID' instruction of Pentium... :( )

How can I do this??? :(
Where can I find this code??? :confused:

Thank you for reading!
Have a nice day!
Posted on 2002-07-01 00:41:07 by nyam
I remember i ave seen such code for 8086, 8186,80286,80386,80486 in some OS bootloaders or/in Linux bootloader source code...

i might have to search my HDD if you can not find those yourself
Posted on 2002-07-01 02:57:18 by BogdanOntanu
this is a code snippet I found:

pushfd ; save extended flags
mov eax,040000h
push eax ; push 40000h onto stack
popfd ; pop extended flags
pushfd ; push extended flags
pop eax ; put in eax
and eax,040000h ; is bit 18 set?
mov al,3
je @F ; no, it's a 386

push dword ptr 200000h; test cpuid opcode
pop eax
test eax,200000h
mov al,4 ; not there, it's a 486
jz @F
mov eax,1 ;get register 1
mov al,ah
Posted on 2002-07-01 03:17:15 by japheth

MachineCheck proc near ;Teste CPU-Typ (offizielle INTEL Methode...
;...aber schwachsinnig)
xor ax,ax ;Pushe 0...
push ax ;auf den Stack
popf ;Ziehe Flags runter
pushf ;Pushe sie wieder drauf
pop ax ;und wieder in AX
and ax,0F000h ;Nimm nur die Bits 11-8
cmp ax,0F000h ;Wenn alle gesetzt....
je short MC_8086 ;...dann ist es ein 8086

mov ax,0F000h ;Pushe f00...
push ax ;...auf den Stack
popf ;Ziehe die Flags runter
pushf ;und wieder auf den Stack
pop ax ;Als AX vom Stack
and ax,0F000h ;Nimm nur Bits 11-8
jz short MC_80286 ;Wenn Null, dann 80286

mov ax,3 ;Setze AX=3 f?r 80386/80386SX/80486
ret ;Ende

mc_80286: mov ax,2 ;Setze AX=2 f?r 80286
ret ;Ende

mc_8086: mov ax,1 ;Setze AX=1 f?r 8086/8088
ret ;Ende
MachineCheck endp

Not written by me and not tested :)
Posted on 2002-07-01 04:09:18 by bazik
Being realistic if you write code then its quite unlikly that it will get executed on a 386 or 486 processor and even if it does do, you really need to be able to tell these processors apart?

But anyway, Intel introduced its CPUID instruction in a late model of the 486 processer.

The offical check for the support of the CPUID instruction is to attempt to toggle the EFLAGS.ID bit (Bit 21)

(Untested sorry)


pop eax
xor eax,EFLAGS_ID
push eax
pop edx

and eax,EFLAGS_ID
and edx,EFLAGS_ID
.IF eax!=edx ;CPUID is supported -> 586+ (Unless late model 486)
.ELSE ;CPUID is not supported -> 386 or 486
Posted on 2002-07-01 05:31:49 by huh
szCaption db 'Chris Dragan''s CPU Identification Utility', 0

But you will need to hunt it on Google.

Enjoy your work, P1
Posted on 2002-07-01 08:42:46 by Pone
Here is Chris Dragan?s cpuid tool
Posted on 2002-07-01 11:28:47 by ante
Also found some good pdf files from Amd and Intel
Posted on 2002-07-01 11:40:25 by ante
The second pdf, was too big to zip both in one file
Posted on 2002-07-01 11:43:58 by ante
Thank you for all who post reply.

Especially, Thanks ante for replying sample code.

Have a nice day all! :)
Posted on 2002-07-01 19:04:32 by nyam
CPUID doesnt work on my amd.
Posted on 2002-07-02 20:41:38 by Qages
CPUID doesnt work on my amd.

Unless you have an old processor that does not support it, try using my sample code above to toggle and test the ID bit in the EFLAGS register.

Otherwise the only thing that I can think of is that you are not using the instruction with the correct register values.
Posted on 2002-07-02 21:55:54 by huh
AMD/Cyrix CPU's can dynamically enable and disable this CPUID instruction. They come disabled by default. You need a program to enable it.
Weird cuz my T-Bird supports it =\
Posted on 2002-07-08 14:50:58 by x86asm

AMD/Cyrix CPU's can dynamically enable and disable this CPUID instruction. They come disabled by default. You need a program to enable it.

Ummm, what?
I never heard about that before, nor can I see a reason why it
would be done.

Anyway, as suggested before, you should always try flipping the
ID bit in eflags before issuing CPUID. You hardly need to determine
if the processor is a 80386 these days, as you wont be booting
any pmode OS on something less than this :).
Posted on 2002-07-08 18:59:04 by f0dder
I had a Cyrix 6x86 processor man I know this. Their is a flag in one of the Control Registers (I think that is where it is located) in which you can toggle the CPUID instruction. Windows95 read my CPU as a 80486 when it was disabled and as a Pentium when enabled!!
Posted on 2002-07-08 19:00:49 by x86asm
Everyone should go to http://www.sandpile.org/ia32/cpuid.htm there is a complete list on how to determine the processor's capabilities.
Posted on 2002-07-08 19:16:11 by stryker
Cyrix sucks. :D
Lets not talk about those sweat-shop made CPUs.
Posted on 2002-07-08 23:21:53 by comrade
Lets not talk about those sweat-shop made CPUs.
I've heard a rumor on the web that some AMD chips were/are made on sweat shops??? Is this true?? Can't remember the site.
Posted on 2002-07-08 23:35:56 by stryker
Posted on 2002-07-08 23:59:10 by comrade
OMG, not that again comrade. :grin:
Posted on 2002-07-09 00:18:04 by bitRAKE