; CPUTYPE.INC Routines to determine CPU type for high level languages ; (Pascal,C,C++,etc) ; CPU: 8086/80186, 80286, 80386, 80486, 80586 Pentium, 80686 P6 and higher(!) ; FPU: 8087, 80287, 80387, 80487, and higher (see 1. and 2. in CPU586P6.ASM) ; ; 1995 by XMAS coding (Dominik Freche, address see below) ; ********************** NOTE ********************** ; For further pieces of information see CPU586P6.ASM ; ************************************************** ; ; !!!!! THIS SOURCECODE IS FREEWARE !!!!! ; Including routines in high level languages (Pascal,C,C++,etc) : ; First assemble this file (for TASM : TASM CPUTYPE.INC) to an Object-file ; (*.OBJ). This file can be included in your high level language program. ; Add these lines in your high level language main (!) program ; (e.g. for Turbo-Pascal) : ; {$L CPUTYPE.OBJ} ; Function CPUType : Word; External;{1=86,2=286,3=386,4=486,5=586,etc.} ; Function FPUType : Word; External;{0=None,1=87,2=287,3=387,4=487,Internal} ; For other languages use another syntax. ; ; If you have got any problems or if you want to contact me, do not hesitate, ; please write to the following address : ; Dominik Freche ; Vondernstrasse 45 ; 45357 Essen ; Germany, Europe ; or email to : ; heckenb@mi.uni-erlangen.de (Frank Heckenbach) ; ; Dominik Freche, Mar 26 1995 ; Inclusion routines : LOCALS @@ getcputype: ;>AX CpuType (1=86,2=286,3=386,4=486,5=586,6=686,etc.) MOV AX,1 PUSHF POP BX AND BH,0FH PUSH BX POPF PUSHF POP CX AND CH,0F0H CMP CH,0F0H JE @@1 ;8086 or below 80286 ;286 INC AX OR BH,0F0H PUSH BX POPF PUSHF POP CX AND CH,0F0H JE @@1 ;80286 ;386 INC AX MOV EBX,ESP AND ESP,0FFFCH PUSHFD POP EDX MOV ECX,EDX XOR EDX,000040000H PUSH EDX POPFD PUSHFD POP EDX PUSH ECX POPFD XOR EDX,ECX AND EDX,000040000H ;Test Alignment Check Bit MOV ESP,EBX JZ @@1 ;80386 ;486 INC AX PUSHFD POP EDX MOV ECX,EDX XOR EDX,000200000H PUSH EDX POPFD PUSHFD POP EDX PUSH ECX POPFD XOR EDX,ECX ;Test ID Bit JZ @@1 ;80486 MOV EAX,1 ;586 or higher, CPUID returns Cpu Generation Number in AX Bits 8-11 DB 0FH,0A2H ;CPUID-instruction AND AH,0FH SHR AX,8 @@1: RET