$CPU 8086 ' make compatible with XT systems $LIB ALL OFF ' turn off all PowerBASIC libraries $ERROR ALL OFF ' turn off all PowerBASIC error checking $OPTIMIZE SIZE ' optimize for smaller code $COMPILE UNIT ' compile to a UNIT (.PBU) '$COMPILE EXE ' compile to a UNIT (.PBU) DEFINT A-Z ' Required for all numeric functions, forces PB to not ' include floating point in UNIT (makes it smaller) '/*------------------------------------------------------------------*/ $CODE SEG "MLIB4" '/*------------------------------------------------------------------*/ ' CPU(OPT) ' Returns the CPU type. ' OPT: 0 = Return number string only. ' 1 = Return verbose description. ' EXAMPLE: T$ = CPU(0) ' 5' ' T$ = CPU(1) 'Intel Pentium' ' Return Codes: 0 = 8086/8088 ' 1 = 80186 ' 2 = 80286 ' 3 = 80386 ' 4 = 80486 ' 5 = 80586 Pentium ' 6 = 80686 Pentium Pro ' 7 = > 80686 ' 255 = V20/V30 '/*------------------------------------------------------------------*/ FUNCTION CPU(OPT%) PUBLIC AS STRING LOCAL Prozessor? DIM Vendor AS STRING * 12 ! pushf ! mov ax, &h0000 ! push ax ! popf ! pushf ! pop ax ! and ax, &hF000 ! cmp ax, &hF000 ! jnz Teste286 ! mov ax, &hFFFF ! mov cl, &h21 ! shl ax, cl ! jnz Setze186 ! mov Prozessor?, &h00 ! popf ! xor ax, ax ! mov al, &h40 ! mul al ! jz SetzeNEC ! jmp CPUEnde Setze186: ! mov Prozessor?, &h01 ! popf ! jmp CPUEnde SetzeNEC: ! mov Prozessor?, &hFF ! jmp CPUEnde Teste286: ! mov ax, &h7000 ! push ax ! popf ! pushf ! pop ax ! and ax, &h7000 ! jnz Teste386 ! mov Prozessor?, &h02 ! popf ! jmp CPUEnde Teste386: ! mov bx, sp ! and sp, &hFFFC ! db &h66 ! pushf ! db &h66 ! pop ax ! db &h66 ! mov cx, ax ! db &h66 ! xor ax, &h0000 ! dw &h0004 ! db &h66 ! push ax ! db &h66 ! popf ! db &h66 ! pushf ! db &h66 ! pop ax ! db &h66 ! xor ax, cx ! mov Prozessor?, &h03 ! mov sp, bx ! jz CPUEnde ! and sp, &hFFFC ! db &h66 ! push cx ! db &h66 ! popf ! mov sp, bx Teste486: ! mov Prozessor?, &h04 ! db &h66 ! mov ax, cx ! db &h66 ! xor ax, &h0000 ! dw &h0020 ! db &h66 ! push ax ! db &h66 ! popf ! db &h66 ! pushf ! db &h66 ! pop ax ! db &h66 ! xor ax, cx ! je CPUEnde TesteCPUID: ! db &h66 ! xor ax, ax ! inc ax ! dw &hA20F ! and ah, &h0F ! mov Prozessor?, ah ! xor ax, ax ! dw &hA20F ! db &h66 ! mov Vendor$[00], bx ! db &h66 ! mov Vendor$[04], dx ! db &h66 ! mov Vendor$[08], cx CPUEnde: SELECT CASE Vendor$ CASE "GenuineIntel": Manufacturer$ = "Intel " CASE "AuthenticAMD": Manufacturer$ = "AMD " CASE "NexGenDevice": Manufacturer$ = "NexGen " CASE "UMC UMC UMC ": Manufacturer$ = "Cyrix " CASE ELSE : Manufacturer$ = "Intel " END SELECT SELECT CASE Prozessor? CASE 0 : CPUTyp$ = "Intel 8088/8086" CASE 1 : CPUTyp$ = "Intel 80186" CASE 2 : CPUTyp$ = "Intel 80286" CASE 3 : CPUTyp$ = "Intel 80386" CASE 4 : CPUTyp$ = Manufacturer$ + "80486" CASE 5 : CPUTyp$ = Manufacturer$ + "Pentium" CASE 6 : CPUTyp$ = Manufacturer$ + "Pentium Pro" CASE 255: CPUTyp$ = "NEC V20/V30" CASE ELSE: CPUTyp$ = "Intel 80" + CHR$(Prozessor? + 48) + "86" END SELECT IF OPT% = 0 THEN FUNCTION = LTRIM$(STR$(Prozessor?)) IF OPT% = 1 THEN FUNCTION = CPUTyp$ END FUNCTION '/*------------------------------------------------------------------*/ 'PRINT "Identified CPU: "; CPU(0) 'PRINT "Identified CPU: "; CPU(1) 'input z 'END