📄 chipstc.lst
字号:
Turbo Assembler Version 1.0 02-09-90 21:24:44 Page 1
CHIPSTC.ASM
chips() - CPU and Math Coprocessor (NDP) Type Check
1
2 ; calling convention:
3 ;
4 ; int chips( void );
5 ;
6 ; returns:
7 ;
8 ; tucked away neatly in your AX....
9 ;
10 ; you get back 8x if an 8088/8086
11 ; 18x if an 80186/80188
12 ; 28x if an 80286
13 ; 38x if an 80386
14 ; 20x for a NEC V20/V30
15 ; AND
16 ; xx0 if NO NDP is found
17 ; xx1 if an 8087
18 ; xx2 if an 80287
19 ; xx3 for an 80387
20 ;
21 ; OR.....
22 ;
23 ; >>> A return of 280 means you got an 80286 machine with no NDP, <<<
24 ; >>> 383 means you have an 80386/80387 rig to work with, and a <<<
25 ; >>> return of 81 sez that you have 8088/8086 CPU with an 8087. <<<
26 ; >>> A 200 tells you that you got an NEC V20/V30 without an NDP. <<<
27 ; >>> ETC., Etc., etc. <<<
28 ;
29 ; NOTE:
30 ;
31 ; There are lotsa ways of handling the way this function returns
32 ; it's data. For my purposes, I have elected this one because
33 ; it requires only int arithmetic on the caller's end to extract
34 ; all the info I need from the return value. I think that I'm
35 ; well enough 'commented' in the following code so that you will
36 ; be able to tinker and Putz until you find the best return tech-
37 ; nique for Ur purposes without having to reinvent the wheel.
38 ;
39 ; >>>> Please see TEST.C, enclosed in this .ZIP. <<<<
40 ;
41 ; REFERENCES:
42 ;
43 ; _chips is made up of two PROC's, cpu_type and ndp_type.
44 ;
45 ; cpu_type is based on uncopyrighted, published logic by
46 ; Clif (that's the way he spells it) Purkiser of Intel -
47 ; Santa Clara.
48 ;
49 ; ndp_type is adopted from Ted Forgeron's article in PC
50 ; Tech Journal, Aug '87 p43.
51 ;
52 ; In the event of subsequent republication of this function,
53 ; please carry forward reference to these two gentlemen as
54 ; original authors.
55 ;
56 ; Copr. 1987 Pat Shea - Psi! (that Copr. is on there cuz my
Turbo Assembler Version 1.0 02-09-90 21:24:44 Page 2
CHIPSTC.ASM
chips() - CPU and Math Coprocessor (NDP) Type Check
57 ; lawyer sez I should, but feel
58 ; free to hack away!!! pats.)
59 ;
60 ;------------------------------------------------------------------------
61 ;
62 ; 02/09/90 - Program modified to work with TurboC 2.0:
63 ;
64 ; Here is a quick example of how the code is used from TurboC 2.0:
65 ;
66 ;
67 ; int chips (void); ; declare external CHIPS routine
68 ;
69 ; main ()
70 ; {
71 ; return (chips ()); ; return result as DOS errorlevel
72 ; }
73 ;
74 ;
75 ; Notes:
76 ;
77 ; 1) You need to link the CHIPS.OBJ file into the
78 ; TurboC program with either a project file or
79 ; by adding it to you .LIB libaries.
80 ;
81 ; 2) The included CHIPS.OBJ file is compiled for
82 ; the Tiny, Small and Compact memory models.
83 ;
84 ; 3) To use thw Medium, Large and Huge memory
85 ; models refer to pp 366-367 of the Turbo C
86 ; User's Guide manual.
87 ;
88 ; 4) If you re-assemble this file make sure you use
89 ; case sensitivity on symbols (/ml switch for TASM)
90 ;
91 ;
92 ; - Henrik Schmiediche
93 ;
94
95
96 0000 _TEXT SEGMENT BYTE PUBLIC 'CODE'
97 ASSUME CS:_TEXT,DS:DGROUP
98
99 PUBLIC _chips
100
101 0000 _chips PROC NEAR
102
103 0000 0000 control dw 0 ; control word needed for the NDP test
104
105 0002 55 push BP ; save where Ur at
106 0003 8B EC mov BP,SP ; going in.....
107 0005 57 push DI
108 0006 56 push SI
109 0007 51 push CX ; not really needed for MSC but kinda
110 ; nice to do cuz someone else might
111 ; want to use the function and we do
112 ; use CX later on
Turbo Assembler Version 1.0 02-09-90 21:24:44 Page 3
CHIPSTC.ASM
chips() - CPU and Math Coprocessor (NDP) Type Check
113
114 0008 E8 000A call cpu_type ; find out what kinda CPU you got and
115 ; and save it in DX for future reference
116 000B E8 004E call ndp_type ; check for math coprocessor (NDP) type
117 ; and hold that result in AX
118
119 000E 03 C2 add AX,DX ; add the two results together and hold
120 ; 'em in AX for Ur return to the caller
121
122 0010 59 pop CX ; put things back the way that you
123 0011 5E pop SI ; found 'em when you started this
124 0012 5F pop DI ; little drill off.....
125 0013 5D pop BP
126 ; AND
127 0014 C3 ret ; go back to where you came from....
128 ; ( ===> the calling program )
129 ; with Ur results sittin' in AX !!
130 0015 _chips endp
131
132
133 0015 cpu_type PROC NEAR
134
135 0015 9C pushf ; pump Ur flags register onto the stack
136 0016 33 D2 xor DX,DX ; blow out Ur DX and AX to start off
137 0018 33 C0 xor AX,AX ; with a clean slate
138 001A 50 push AX ; put AX on the stack
139 001B 9D popf ; bring it back in Ur flags
140 001C 9C pushf ; try to set bits 12 thru 15 to a zero
141 001D 58 pop AX ; get back Ur flags word in AX
142 001E 25 F000 and AX, 0f000h ; if bits 12 thru 15 are set then you got
143 0021 3D F000 cmp AX, 0f000h ; an Intel 8018x or a 808x or maybe even
144 0024 74 16 jz dig ; a NEC V20/V30 ??? - gotta look more...
145
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -