;this routine identifies the PC'S 80X86 microprocessor ;upon return from this subroutine, AX contains microprocessor code ;where 0=8088/86,1=286,3=386,4=486, 5=Pentium, 6=Pentium Pro GET_CPUID PROC ; ;see if it is 8086/88 by checking bits d12-d15 of flag reg PUSHF ;push the flag into stack POP BX ;and get it into BX AND BX,0FFFH ;mask bits d15-d12 PUSH BX ;send it back into stack POPF ;bring it back into flag reg PUSHF ;store the flag back on stack again POP BX ;and get it back into BX AND BX,0F000H ;mask all bits except d12-d15 CMP BX,0F000H ;are the d12-d15 all zeros? MOV AX,0 ;make AX=0 code for 8088/86 JE OVER ;if yes then AX=0 code for 8086/88 ;see if it is 80286 by checking bits of d12-d15 of flag reg OR BX,0F000H ;if not try setting d12-d15 to high PUSH BX ;push it into stack POPF ;make d12-d15 of flag reg all 1s PUSHF ;get the flag back into stack POP BX ;get it back to examine the bits AND BX,0F000H ;mask all bits except d12-d15 CMP BX,0F000H ;are d12-d15 all 1s MOV AX,1 ;make AX=1 code for 286 JE OVER ;if yes set AX=1 code for 286 ;see if it is 386 by checking bit 18 of flag bit .386 PUSHFD ;if not it is 386 or higher. push flag POP EBX ;and get it into EBX MOV EDX,EBX ;save it XOR EBX,40000H ;flip bit 18 PUSH EBX ;sent it into stack POPFD ;get it into flag PUSHFD ;get it back into stack POP EBX ;get the new flag back into EBX MOV AX,3 ;make AX=3 code for 386 XOR EBX,EDX ;see if bit 18 is toggled JE OVER ;if yes then AX=3 CODE for the 386 ;see if it is 486 or higher. try changing bit 21 of flag reg MOV AX,4 ;if not it is 486 or higher (AX=4 for 486) PUSHFD ;see if bit 21(ID bit) can be altered POP EBX ;in order to use the CPUID instruction MOV EDX,EBX ;save original flag bit in EDX XOR EBX,200000H ;flip bit 21 PUSH EBX ;save it on the stack POPFD ;get it into flag reg PUSHFD ;get flag back into stack POP EBX ;get it into EBX to examine bit 21 XOR EBX,EDX ;see if bit 21 changes JE OVER ;if yes AX=04 code for 486 ;see which pentium (586,or 686) by using CPUID instruction MOV EAX,1 ;set EAX=1 before executing CPUID .586 ;use Pentium instruction CPUID ;after execution of CPUID, bits D8-D11 of EAX have family number .386 ;back to 386 instructions AND EAX,0F00 ;mask all bits except the family bit SHR EAX,8 ;move d8-d11 to lower nibble then AX=5 for Pentium, 6 for Pentium Pro .8086 OVER: RET ;return with AX=processor number GET_CPUID ENDP