-
Notifications
You must be signed in to change notification settings - Fork 5
/
CI.ASM
338 lines (321 loc) · 5.41 KB
/
CI.ASM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
.8086
Code Segment Public
Assume CS:Code
extrn CPU
Public CITest,ChkCPUMhz,GetPChrMhz,GetPChrWaitStates,GetPChrGeneral
cpu8088 equ 0
cpu8086 equ 1
cpu80188 equ 2
cpu80186 equ 3
cpu80286 equ 4
cpu80386 equ 5
ClockBalance DW 0EDBh
DW 0EDBh
DW 0EDBh
DW 0EDBh
DW 0800h
DW 0800h
DW 0944h
DW 0958h
DW 0958h
DW 0958h
DW 0958h
DW 0958h
DW 0958h
DW 0958h
ClockBalanceEnd DW 4000h
DW 4000h
DW 4000h
DW 4000h
DW 8000h
DW 8000h
DW 0000h
DW 0000h
DW 0000h
DW 0000h
DW 0000h
DW 0000h
DW 0000h
DW 0000h
ClockBalanceSub DW 1BDAh
DB 0DAh, 1Bh
DW 1BDAh
DB 0DAh, 1Bh
DB 1Fh, 0Dh
DB 1Fh, 0Dh
DB 8Eh, 6
DB 8Eh, 6
DB 8Eh, 6
DB 8Eh, 6
DB 8Eh, 6
DB 8Eh, 6
DB 8Eh, 6
DB 8Eh, 6
;data_7 DW 0
data_8 DW 0
data_9 DW 0
data_10 DW 0
data_11 DW 0
data_12 DW 0
data_13 DW 0
data_14 DW 0
StrNmMhz DB 8 DUP (0)
StrWaitState DB 12 DUP (0)
FactorRelative DB 10 DUP (0)
data_32 DW 64h
data_33 DW 0
DB 11 DUP (0)
CITest Proc Pascal Far
CALL Far Ptr ChkCPUMhz
CALL sub_5
MOV SI,Offset StrWaitState
CALL ComputeString
MOV Byte Ptr CS:[SI],0
CALL GeneralRelativeFactor
RET
CITest endp
ChkCPUMhz Proc Pascal Far
CLD
CALL StartTime
MOV BL,Byte Ptr DS:CPU
XOR BH,BH
SHL BX,1
MOV CX,Word Ptr CS:ClockBalanceEnd[BX]
XOR DX,DX
MOV AX,DX
MOV BX,0FFFFh
STI
@4:
DIV BX ; ax,dx rem=dx:ax/reg
DIV BX ; ax,dx rem=dx:ax/reg
DIV BX ; ax,dx rem=dx:ax/reg
DIV BX ; ax,dx rem=dx:ax/reg
DIV BX ; ax,dx rem=dx:ax/reg
DIV BX ; ax,dx rem=dx:ax/reg
DIV BX ; ax,dx rem=dx:ax/reg
DIV BX ; ax,dx rem=dx:ax/reg
DIV BX ; ax,dx rem=dx:ax/reg
DIV BX ; ax,dx rem=dx:ax/reg
DIV BX ; ax,dx rem=dx:ax/reg
DIV BX ; ax,dx rem=dx:ax/reg
DIV BX ; ax,dx rem=dx:ax/reg
DIV BX ; ax,dx rem=dx:ax/reg
DIV BX ; ax,dx rem=dx:ax/reg
DIV BX ; ax,dx rem=dx:ax/reg
LOOP @4 ; LOOP si CX>0
CLI
CALL EndTime
; STI
MOV AX,Word Ptr CS:data_14
MOV Word Ptr CS:data_11,AX
MOV BL,DS:Byte Ptr CPU
XOR BH,BH
SHL BX,1
MOV AX,Word Ptr CS:ClockBalance[BX]
MOV Word Ptr CS:data_8,AX
MOV Word Ptr CS:data_12,AX
MOV SI,Offset StrNmMhz
JMP @8
sub_5:
; CLI
CALL StartTime
PUSH DS
XOR AX,AX
MOV DS,AX
MOV ES,AX
MOV DX,40h
STI
@6:
MOV CX,0FFFFh
XOR SI,SI
MOV DI,SI
REPNE MOVSB ; R‚pŠte zf=0+cx>0 d‚place DS:[SI] dans ES:[DI]
DEC DX
JNZ @6
CLI
POP DS
CALL EndTime
; STI
MOV AX,Word Ptr CS:data_14
MUL Word Ptr CS:data_12
DIV Word Ptr CS:data_11
MOV BL,DS:Byte Ptr CPU
XOR BH,BH
SHL BX,1
SUB AX,Word Ptr CS:ClockBalanceSub[BX]
JBE @5
XOR DX,DX
MOV BX,347h
DIV BX ; ax,dx rem=dx:ax/reg
RET
@5:
XOR AL,AL
RET
endp
GeneralRelativeFactor Proc Near
; CLI
CALL StartTime
PUSH CS
POP ES
;MOV SI,CS:data_33
MOV SI,Offset data_33
MOV DI,SI
XOR CX,CX
; STI
@7:
MOV AX,ES:[SI]
OR ES:[DI],AX
DEC DX
INC DX
MOV AX,ES:[SI]
OR ES:[DI],AX
DEC DX
INC DX
MOV AX,ES:[SI]
OR ES:[DI],AX
DEC DX
INC DX
MOV AX,ES:[SI]
OR ES:[DI],AX
DEC DX
INC DX
MOV AX,ES:[SI]
OR ES:[DI],AX
DEC DX
INC DX
MOV AX,ES:[SI]
OR ES:[DI],AX
DEC DX
INC DX
LOOP @7 ; LOOP si cx > 0
; CLI
CALL EndTime
; STI
MOV Word Ptr CS:data_8,228h
MOV SI,Offset FactorRelative
@8:
MOV AX,Word Ptr CS:data_8
XOR DX,DX
DIV Word Ptr CS:data_14
MOV Word Ptr CS:data_9,AX
MOV AX,DX
MUL Word Ptr CS:data_32
DIV Word Ptr CS:data_14
AAM
CMP AL,5
JB @9
INC AH
CMP AH,0Ah
JB @9
XOR AH,AH
ADD Word Ptr CS:data_9,1
@9:
MOV AL,AH
XOR AH,AH
MOV Word Ptr CS:data_10,AX
MOV AX,Word Ptr CS:data_9
CALL ComputeString
MOV Byte Ptr CS:[SI],','
INC SI
MOV AX,Word Ptr CS:data_10
CALL ComputeString
MOV Byte Ptr CS:[SI],0
RET
endp
ComputeString Proc Near
MOV BX,64h
XOR DX,DX
DIV BX
XCHG AX,DX
AAM
MOV CX,AX
MOV AX,DX
XOR DX,DX
DIV BX
XCHG AX,DX
AAM
MOV BX,AX
OR DL,DL
JNZ @11
OR BH,BH
JNZ @12
OR BL,BL
JNZ @13
OR CH,CH
JNZ @14
@10:
ADD CL,30h ; '0'
MOV CS:[SI],CL
INC SI
RET
@11:
ADD DL,30h ; '0'
MOV CS:[SI],DL
INC SI
@12:
ADD BH,30h ; '0'
MOV CS:[SI],BH
INC SI
@13:
ADD BL,30h ; '0'
MOV CS:[SI],BL
INC SI
@14:
ADD CH,30h ; '0'
MOV CS:[SI],CH
INC SI
JMP Short @10
ComputeString endp
GetMillisecondsTimer Proc Near
XOR AX,AX
MOV ES,AX
CLI
MOV AX,ES:[46Ch]
STI
MOV BX,88
MUL BX
MOV CL,4
SHR AX,4
MOV CL,12
SHL DX,CL
OR AX,DX
RET
GetMillisecondsTimer endp
tmptime DW 0
StartTime Proc Near
CALL GetMillisecondsTimer
MOV tmptime,AX
waitnoset:
CALL GetMillisecondsTimer
CMP AX,tmptime
JE waitnoset
MOV CS:data_13,AX
RET
StartTime endp
EndTime Proc Near
CALL GetMillisecondsTimer
CMP AX,CS:data_13
JAE @15
ADD AX,1770h
@15:
SUB AX,CS:data_13
MOV Word Ptr CS:data_14,AX
RET
EndTime endp
GetPChrMhz Proc Far
MOV DX,CS
MOV AX,Offset StrNmMhz
RET
GetPChrMhz endp
GetPChrWaitStates Proc Far
MOV DX,CS
MOV AX,Offset StrWaitState
RET
GetPChrWaitStates endp
GetPChrGeneral Proc Far
MOV DX,CS
MOV AX,Offset FactorRelative
RET
GetPChrGeneral endp
code ends
end