Cleanup
This commit is contained in:
parent
70ddfc73d0
commit
5575d6e3fa
1 changed files with 643 additions and 626 deletions
|
|
@ -1,3 +1,4 @@
|
|||
; Posted in comp.sys.ibm.pc by Michael A. Shiels 8/16/89
|
||||
; From https://groups.google.com/forum/#!searchin/comp.sys.ibm.pc/single-step$20interrupt/comp.sys.ibm.pc/irWPIdzmCHQ/SyqEtq9mqCEJ
|
||||
|
||||
title CPUID - Determine CPU & NDP Type
|
||||
|
|
@ -83,8 +84,7 @@
|
|||
; Assembly requirements:
|
||||
;
|
||||
; Use MASM 1.25 or later.
|
||||
; With IBM's MASM 2.0 only, use /S to avoid alphabetizing the
|
||||
; segment names.
|
||||
; With IBM's MASM 2.0 only, use /S to avoid alphabetizing the segment names.
|
||||
; Use /r option to generate real NDP code.
|
||||
;
|
||||
; MASM CPUID/r; to convert .ASM to .OBJ
|
||||
|
|
@ -96,7 +96,9 @@
|
|||
;
|
||||
; Author:
|
||||
;
|
||||
; Original code by: Bob Smith May 1985
|
||||
; Original code by:
|
||||
;
|
||||
; Bob Smith May 1985
|
||||
; Qualitas, Inc.
|
||||
; 8314 Thoreau Dr.
|
||||
; Bethesda, MD 20817
|
||||
|
|
@ -106,11 +108,12 @@
|
|||
; length of their pre-fetch instruction queues.
|
||||
;
|
||||
; Published in PC Tech Journal - April 1986 - Vol 4 No 4
|
||||
|
||||
;
|
||||
subttl Structures, Records, Equates, & Macros
|
||||
page
|
||||
ARG_STR struc
|
||||
dw ? ; caller's bp
|
||||
|
||||
ARG_STR struct
|
||||
ARG_BP dw ? ; caller's BP
|
||||
ARG_OFF dw ? ; caller's offset
|
||||
ARG_SEG dw ? ; segment
|
||||
ARG_FLG dw ? ; flags
|
||||
|
|
@ -118,12 +121,11 @@ ARG_STR ends
|
|||
|
||||
; Record to define bits in the CPU's & NDP's flags' registers
|
||||
|
||||
CPUFLAGS record RO:1,NT:1,IOPL:2,OF:1,DF:1,IF:1,TF:1,SF:1,ZF:1,R1:1,AF:1,R2:1,PF:1,R3:1,CF:1
|
||||
CPUFLAGS record RO:1,NT:1,IOPL:2,OF:1,_DF:1,_IF:1,TF:1,SF:1,ZF:1,R1:1,AF:1,R2:1,PF:1,R3:1,CF:1
|
||||
|
||||
NDPFLAGS record R4:3,IC:1,RC:2,PC:2,IEM:1,R5:1,PM:1,UM:1,OM:1,ZM:1,DM:1,IM:1
|
||||
|
||||
; FLG_PIQL Pre-fetch instruction queue length, 0 => 4-byte
|
||||
; 1 => 6-byte
|
||||
; FLG_PIQL Pre-fetch instruction queue length, 0 => 4-byte, 1 => 6-byte
|
||||
; FLG_08 Intel 808x
|
||||
; FLG_NEC NEC V20 or V30
|
||||
; FLG_18 Intel 8018x
|
||||
|
|
@ -166,11 +168,11 @@ POPFF macro
|
|||
local L1,L2
|
||||
jmp short L2 ; skip over IRET
|
||||
L1:
|
||||
iret ; pop the cs & ip pushed below along
|
||||
iret ; pop the CP & IP pushed below along
|
||||
; with the flags, our original purpose
|
||||
L2:
|
||||
push cs ; prepare for IRET by pushing cs
|
||||
call L1 ; push ip, jump to IRET
|
||||
push cs ; prepare for IRET by pushing CS
|
||||
call L1 ; push IP, jump to IRET
|
||||
endm ; POPFF macro
|
||||
|
||||
TAB macro TYP
|
||||
|
|
@ -184,7 +186,9 @@ TAB macro TYP
|
|||
mov ah,09h ; function code to display string
|
||||
int 21h ; request dos service
|
||||
endm ; TAB macro
|
||||
|
||||
page
|
||||
|
||||
INT_VEC segment at 0 ; start INT_VEC segment
|
||||
dd ? ; pointer to INT 00h
|
||||
INT01_OFF dw ? ; pointer to INT 01h
|
||||
|
|
@ -204,6 +208,7 @@ STACK ends ; end STACK segment
|
|||
I11_REC record I11_PRN:2,I11_RSV1:2,I11_COM:3,I11_RSV2:1,I11_DISK:2,I11_VID:2,I11_RSV3:2,I11_NDP:1,I11_IPL:1
|
||||
|
||||
DATA segment byte public 'data' ; start DATA segment
|
||||
|
||||
assume ds:PGROUP
|
||||
|
||||
OLDINT01_VEC label dword ; save area for original INT 01h handler
|
||||
|
|
@ -218,7 +223,9 @@ NDP_ENV dw 7 dup(?) ; save area for NDP environment
|
|||
DATA ends
|
||||
subttl Message Data Area
|
||||
page
|
||||
|
||||
MDATA segment byte public 'data' ; start MDATA segment
|
||||
|
||||
assume ds:PGROUP
|
||||
|
||||
MSG_START db 'CPUID -- Version 1.0'
|
||||
|
|
@ -240,8 +247,7 @@ MSG_UNK db 'CPU is a maverick -- 80288??.'
|
|||
MSG_80286 db 'CPU is an Intel 80286.'
|
||||
db CR,LF,EOS
|
||||
|
||||
CPUMSG_TAB label word
|
||||
dw PGROUP:MSG_8088 ; 000 = Intel 8088
|
||||
CPUMSG_TAB dw PGROUP:MSG_8088 ; 000 = Intel 8088
|
||||
dw PGROUP:MSG_8086 ; 001 = Intel 8086
|
||||
dw PGROUP:MSG_V20 ; 010 = NEC V20
|
||||
dw PGROUP:MSG_V30 ; 011 = NEC V30
|
||||
|
|
@ -250,8 +256,7 @@ CPUMSG_TAB label word
|
|||
dw PGROUP:MSG_UNK ; 110 = ?
|
||||
dw PGROUP:MSG_80286 ; 111 = Intel 80286
|
||||
|
||||
NDPMSG_TAB label word
|
||||
dw PGROUP:MSG_NDPX ; 00 = No NDP
|
||||
NDPMSG_TAB dw PGROUP:MSG_NDPX ; 00 = No NDP
|
||||
dw PGROUP:MSG_8087 ; 01 = Intel 8087
|
||||
dw PGROUP:MSG_80287 ; 10 = Intel 80287
|
||||
|
||||
|
|
@ -262,36 +267,36 @@ MSG_8087 db 'NDP is an Intel 8087.'
|
|||
MSG_80287 db 'NDP is an Intel 80287.'
|
||||
db CR,LF,EOS
|
||||
|
||||
CERRMSG_TAB label word
|
||||
dw PGROUP:MSG_CPUOK ; 0 = CPU healthy
|
||||
CERRMSG_TAB dw PGROUP:MSG_CPUOK ; 0 = CPU healthy
|
||||
dw PGROUP:MSG_CPUBAD ; 1 = CPU faulty
|
||||
|
||||
MSG_CPUOK db 'CPU appears to be healthy.'
|
||||
db CR,LF,EOS
|
||||
MSG_CPUBAD label byte
|
||||
db BEL,'*** CPU incorrectly allows interrupts '
|
||||
MSG_CPUBAD db BEL,'*** CPU incorrectly allows interrupts '
|
||||
db 'after a change to SS ***',CR,LF
|
||||
db 'It should be replaced with a more recent '
|
||||
db 'version as it could crash the',CR,LF
|
||||
db 'system at seemingly random times.',CR,LF,EOS
|
||||
|
||||
NERRMSG_TAB label word
|
||||
dw PGROUP:MSG_NDPSWOK ; 0 = NDP switch set correctly
|
||||
NERRMSG_TAB dw PGROUP:MSG_NDPSWOK ; 0 = NDP switch set correctly
|
||||
dw PGROUP:MSG_NDPSWERR ; 1 = NDP switch set incorrectly
|
||||
|
||||
MSG_NDPSWOK db EOS ; no message
|
||||
MSG_NDPSWERR label byte
|
||||
db '*** Although there is an NDP installed '
|
||||
MSG_NDPSWERR db '*** Although there is an NDP installed '
|
||||
db 'on this sytem, the corresponding',CR,LF
|
||||
db 'system board switch is not properly set. '
|
||||
db 'To correct this, flip switch 2 of',CR,LF
|
||||
db 'switch block 1 on the system board.',CR,LF,EOS
|
||||
|
||||
MDATA ends ; end MDATA segment
|
||||
|
||||
subttl Main Routine
|
||||
page
|
||||
|
||||
CODE segment byte public 'prog' ; start CODE segment
|
||||
|
||||
assume cs:PGROUP,ds:PGROUP,es:PGROUP
|
||||
|
||||
org 100h ; skip over PSP
|
||||
|
||||
INITIAL proc near
|
||||
|
|
@ -299,7 +304,7 @@ INITIAL proc near
|
|||
mov ah,09h ; function code to display string
|
||||
int 21h ; request DOS service
|
||||
|
||||
call CPUID ; check the CPU's identity
|
||||
call CPU_ID ; check the CPU's identity
|
||||
|
||||
TAB CPU ; display CPU results
|
||||
TAB NDP ; display NDP results
|
||||
|
|
@ -308,9 +313,12 @@ INITIAL proc near
|
|||
|
||||
ret ; return to DOS
|
||||
INITIAL endp ; end INITIAL procedure
|
||||
subttl CPUID Procedure
|
||||
|
||||
subttl CPU_ID Procedure
|
||||
page
|
||||
CPUID proc near ; start CPUID procedure
|
||||
|
||||
CPU_ID proc near ; start CPU_ID procedure
|
||||
|
||||
assume cs:PGROUP,ds:PGROUP,es:PGROUP
|
||||
|
||||
; This procedure determines the type of CPU and NDP (if any) in use.
|
||||
|
|
@ -365,7 +373,6 @@ CPUID proc near ; start CPUID procedure
|
|||
shl al,cl ; shift one position if 18x
|
||||
jnz CHECK_PIQL ; some bits still on,
|
||||
; so its a 18x, check PIQL
|
||||
|
||||
; test for V20
|
||||
|
||||
mov bx,FLG_NEC ; assume it's an NEC V-series CPU
|
||||
|
|
@ -373,8 +380,10 @@ CPUID proc near ; start CPUID procedure
|
|||
jcxz CHECK_PIQL ; good guess, check PIQL
|
||||
|
||||
mov bx,FLG_08 ; it's an 808x
|
||||
|
||||
subttl Check Length of Pre-Fetch Instruction Queue
|
||||
page
|
||||
|
||||
; Check the length of the pre-fetch instruction queue (PIQ).
|
||||
;
|
||||
; xxxx6 CPUs have a PIQ length of 6 bytes,
|
||||
|
|
@ -387,14 +396,17 @@ CHECK_PIQL:
|
|||
jcxz CHECK_ERR ; if CX is 0, INC was not executed,
|
||||
; hence PIQ length is 4
|
||||
or bx,FLG_PIQL ; PIQ length is 6
|
||||
|
||||
subttl Check for Allowing Interrupts After POP SS
|
||||
page
|
||||
|
||||
; Test for faulty chip (allows interrupts after change to SS register)
|
||||
|
||||
CHECK_ERR:
|
||||
xor ax,ax ; prepare to address
|
||||
; interrupt vector segment
|
||||
mov ds,ax ; DS points to segment 0
|
||||
|
||||
assume ds:INT_VEC ; tell the assembler
|
||||
|
||||
cli ; nobody move while we swap
|
||||
|
|
@ -417,7 +429,7 @@ CHECK_ERR:
|
|||
or ax,mask TF ; set trap flag
|
||||
push ax ; place onto stack
|
||||
POPFF ; ... and then into effect
|
||||
; some CPUs effect the trap flag
|
||||
; some CPUs affect the trap flag
|
||||
; immediately, some
|
||||
; wait one instruction
|
||||
nop ; allow interrupt to take effect
|
||||
|
|
@ -438,7 +450,7 @@ INT01:
|
|||
push bp ; prepare to address the stack
|
||||
mov bp,sp ; hello, Mr. stack
|
||||
|
||||
cmp [bp].ARG_OFF,offset cs:POST_NOP ; check offset
|
||||
cmp [bp].ARG_STR.ARG_OFF,offset cs:POST_NOP ; check offset
|
||||
pop bp ; restore
|
||||
ja INTO1_DONE ; we're done
|
||||
|
||||
|
|
@ -454,17 +466,19 @@ INTO1_DONE:
|
|||
mov INT01_SEG,es ; ... and segment
|
||||
sti ; allow interrupts again (IF=1)
|
||||
|
||||
add sp,3*2 ; strip ip, cs, and flags from stack
|
||||
add sp,3*2 ; strip IP, CS, and flags from stack
|
||||
|
||||
push cs ; setup ds for code below
|
||||
push cs ; setup DS for code below
|
||||
pop ds
|
||||
assume ds:PGROUP ; tell the assembler
|
||||
|
||||
jcxz CHECK_NDP ; if cx is 0, the dec cx was executed,
|
||||
; and the cpu is ok
|
||||
or bx,mask FLG_CERR ; it's a faulty chip
|
||||
|
||||
subttl Check For Numeric Data Processor
|
||||
page
|
||||
|
||||
; Test for a Numeric Data Processor -- Intel 8087 or 80287. The
|
||||
; technique used is passive -- it leaves the NDP in the same state in
|
||||
; which it is found.
|
||||
|
|
@ -490,6 +504,7 @@ CHECK_NDP:
|
|||
test ax,mask I11_NDP ; check NDP-installed bit
|
||||
jnz CHECK_NDP1 ; it's correctly set
|
||||
or bx,mask FLG_NERR ; mark as in error
|
||||
|
||||
CHECK_NDP1:
|
||||
and NDP_CW,not mask IEM ; enable interrupts
|
||||
; (IEM=0, 8087 only)
|
||||
|
|
@ -505,17 +520,22 @@ CHECK_NDP1:
|
|||
jnz CPUID_8087 ; it changed, hence NDP is an 8087
|
||||
or bx,FLG_287 ; NDP is an 80287
|
||||
jmp short CPUID_EXIT ; exit with falgs in BX
|
||||
|
||||
CPUID_8087:
|
||||
or bx,FLG_87 ; NDP is an 8087
|
||||
|
||||
CPUID_EXIT:
|
||||
irp XX,<es,ds,di,cx,ax> ; restore registers
|
||||
pop XX
|
||||
endm
|
||||
|
||||
assume ds:nothing,es:nothing
|
||||
ret ; return to caller
|
||||
CPUID endp ; end CPUID procedure
|
||||
CPU_ID endp ; end CPU_ID procedure
|
||||
|
||||
subttl Check For NEC V20/V30
|
||||
page
|
||||
|
||||
CHECK_NEC proc near
|
||||
|
||||
; The NEC V20/V30 are very compatible with the Intel 8086/8088.
|
||||
|
|
@ -556,8 +576,10 @@ CHECK_NEC proc near
|
|||
|
||||
ret ; return to caller
|
||||
CHECK_NEC endp
|
||||
|
||||
subttl Pre-Fetch Instruction Queue Subroutine
|
||||
page
|
||||
|
||||
PIQL_SUB proc near
|
||||
|
||||
; This subroutine discerns the length of the CPU's pre-fetch
|
||||
|
|
@ -595,7 +617,6 @@ PIQL_SUB proc near
|
|||
; current instruction is no longer
|
||||
; in the PIQ.
|
||||
; Note at end, CX is 0.
|
||||
|
||||
; The PIQ begins filling here
|
||||
|
||||
cld ; restore direction flag
|
||||
|
|
@ -613,16 +634,12 @@ LAB_STI label byte
|
|||
rept @REP-1
|
||||
sti ; restore interrupts
|
||||
endm
|
||||
|
||||
ret ; return to caller
|
||||
|
||||
assume ds:nothing,es:nothing
|
||||
PIQL_SUB endp ; end PIQL_SUB procedure
|
||||
|
||||
CODE ends ; end code segment
|
||||
|
||||
if1
|
||||
%OUT Pass 1 Complete
|
||||
else
|
||||
%OUT Pass 2 Complete
|
||||
endif
|
||||
|
||||
end INITIAL ; end CPUID module
|
||||
end INITIAL ; end CPU_ID module
|
||||
|
|
|
|||
Loading…
Reference in a new issue