Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CPU Identification 2 of 4

6 views
Skip to first unread message

Michael A. Shiels

unread,
Aug 16, 1989, 7:05:29 AM8/16/89
to

TITLE CPU - PRINT INTEL CPU TYPE ON CONSOLE
; PGMID. CPU.ASM
; AUTHOR. UNKNOWN INTEL EMPLOYEE (MASM V5.0 MAINLINE ADDED BY DON HIGGINS)
; (COMPUSERVE 73047,1113)
; DATE. 11/13/87.
;
; Fixed 05/25/88 73710,3667 TRT
; CMP AX,386 changed to CMP AX,386H
; this change allows this program to identify '386 machines
; much more accurately.
;
DATA SEGMENT PUBLIC
system_type_opt db IBM ;IS THERE A BYTE IN ROM BIOS FOR THIS ?
IBM equ 0
NC_type equ 1
MSGNC DB 'CPU NON COMPATIBLE$'
MSG086 DB 'CPU IS 8086/8088$'
MSG186 DB 'CPU IS 80186$'
MSG286 DB 'CPU IS 80286$'
MSG386 DB 'CPU IS 80386$'
DATA ENDS
STACK SEGMENT STACK
DB 200 DUP(?)
STACK ENDS
CODE SEGMENT PUBLIC
ASSUME CS:CODE,DS:DATA
PUBLIC CPU
CPU LABEL NEAR
MOV AX,DATA
MOV DS,AX
CALL get_cpu_type
CMP AX,86H
JE CPU086
CMP AX,186H
JE CPU186
CMP AX,286H
JE CPU286
CMP AX,386H
JE CPU386
CPUNC LABEL NEAR
MOV DX,OFFSET MSGNC
WTO LABEL NEAR
MOV AH,9
INT 21H
MOV AH,4CH
INT 21H
CPU086 LABEL NEAR
MOV DX,OFFSET MSG086
JMP WTO
CPU186 LABEL NEAR
MOV DX,OFFSET MSG186
JMP WTO
CPU286 LABEL NEAR
MOV DX,OFFSET MSG286
JMP WTO
CPU386 LABEL NEAR
MOV DX,OFFSET MSG386
JMP WTO
;-----------------------------------------------------------------------------;
; ;
; Procedure Name: get_cpu_type ;
; Author: Anonymous Intel Employee ;
; Date: 7/7/87 ;
; Description: This procedure returns the hex value of the processor ;
; type to the calling procedure. It is able to identify ;
; the 8086, 80186, 80286, 80386. ;
; ;
; Parms Passed: None ;
; ;
; Results/Status ;
; Returned: AX = hex digits for the CPU type. ;
; ;
; Calling Sequence: CALL get_CPU_type ;
; ;
; Called By: delete_defective_expanded_memory_pages ;
; ;
; Calls: Nothing ;
; ;
; Registers ;
; Modified: AX ;
; ;
; Globals ;
; Modified/ ;
; Referenced: None ;
; ;
;-----------------------------------------------------------------------------;
get_cpu_type PROC NEAR
PUBLIC get_cpu_type

;---------------------------------------------------------------------;
; If the system type is non-compatible then ;
; return (cpu type = 0) ;
;---------------------------------------------------------------------;
CMP WORD PTR system_type_opt, NC_type
JNE determine_cpu_type
XOR AX, AX
RET

determine_cpu_type:
;---------------------------------------------------------------------;
; Save registers used. ;
;---------------------------------------------------------------------;
PUSHF

;---------------------------------------------------------------------;
; Pop a zero into the FLAGS register and attempt to set bits 15-12 ;
; to zero. ;
; If bits 15-12 = 0 then ;
; the cpu type is an 8018X or an 808X. ;
;---------------------------------------------------------------------;
XOR AX, AX
PUSH AX
POPF
PUSHF
POP AX
AND AX, 0F000h
CMP AX, 0F000h
JNE check_for_80286

check_for_8086_80186:
;---------------------------------------------------------------------;
; Cpu type is an 8086 or 80186. ;
; Shift a pattern of all ones left 33 times. ;
; If shift result = 0 then ;
; cpu type is a 80186 ;
; else ;
; cpu type is a 8086 ;
;---------------------------------------------------------------------;
PUSH CX
MOV AX, 0FFFFh
MOV CL, 33
SHL AX, CL
POP CX
JNZ check_for_80186

check_for_8086:
;---------------------------------------------------------------------;
; Cpu type is an 8086. ;
;---------------------------------------------------------------------;
MOV AX, 86h
POPF
RET

check_for_80186:
;---------------------------------------------------------------------;
; Cpu type is an 80186. ;
;---------------------------------------------------------------------;
MOV AX, 186h
POPF
RET

check_for_80286:
;---------------------------------------------------------------------;
; Attempt to set FLAG bits 14-12 (NT and IOPL bits). ;
;---------------------------------------------------------------------;
MOV AX, 7000h
PUSH AX
POPF
PUSHF
POP AX

;---------------------------------------------------------------------;
; If NT & IOPL bits are not set then ;
; cpu type is and 80286 ;
;---------------------------------------------------------------------;
AND AX, 7000h
JNZ check_for_80386
MOV AX, 286h
POPF
RET

check_for_80386:
;---------------------------------------------------------------------;
; Cpu type is an 80386 ;
;---------------------------------------------------------------------;
MOV AX, 386h
POPF
RET

get_cpu_type ENDP
CODE ENDS
END CPU

0 new messages