-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCGABTEST.PAS
205 lines (189 loc) · 5.38 KB
/
CGABTEST.PAS
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
{$O+,F+}
unit CGABTESTS;
{Contains all of the benchmarking tests/procedures for the CGA compatibility tester}
interface
Procedure BenchReadSpeed;
Procedure BenchWriteSpeed;
Procedure BenchReadSpeedOpcodes;
Procedure BenchWriteSpeedOpcodes;
implementation
uses
strings,m6845ctl,totmsg,ztimer,support,totIO1,totfast,cgaccommon,TInterrupts;
Procedure ReportSpeed(s1:string;bs:word;s2,s3:string;ss:word);
begin
Screen.Write(s1+' '+inttostr(bs)+' '+s2+' ');
Screen.Writeln(inttostr(_PZTimerCount)+' æsecs.');
{if machine is WACKO fast then we need to handle things differently}
if _PZTimerCount=-1 then begin
PrintInvalidMsg;
repeat until keypressed;
PostTest;
exit;
end;
Screen.Writeln(s3+' '+inttostr(round((bs*(1000000/1024)) / _PZTimerCount))+' KB/s.');
Screen.Writeln('A stock 4.77 MHz 8088 IBM PC with original IBM CGA achieves '+inttostr(ss)+' KB/s.');
Screen.Writeln('Press any key to continue.');
repeat until keypressed;
end;
Procedure BenchReadSpeed;
const
BlockSize=$2000;
begin
with InfoPrompt do begin
init(6,strpas(menuLookup[mBMR].title));
WinForm^.vWinPtr^.SetColors(descBorder,descBody,descTitle,descIcons);
AddLine('');
AddLine('This benchmarks your video adapter RAM''s maximum read');
AddLine('speed and displays the result. Use this to compare how');
AddLine('fast (or slow) your adapter is compared to real CGA.');
AddLine('');
SetOption(1,cstring,67,Finished);
SetOption(2,astring,65,Escaped);
Result:=Show;
Done;
end;
if Result=Escaped then exit;
PrepTest;
asm
push ds
mov cx,BlockSize
shr cx,1
mov ax,$b800
mov ds,ax
xor si,si
cld
call _PZTimerOn
rep lodsw
call _PZTimerOff
pop ds
end;
ReportSpeed('Reading',BlockSize,'bytes of your video adapter RAM took',
'Your video RAM''s read speed is',291);
PostTest;
end;
Procedure BenchWriteSpeed;
const
BlockSize=$2000;
begin
with InfoPrompt do begin
init(6,strpas(menuLookup[mBMW].title));
WinForm^.vWinPtr^.SetColors(descBorder,descBody,descTitle,descIcons);
AddLine('');
AddLine('This benchmarks your video adapter RAM''s maximum write');
AddLine('speed and displays the result. Use this to compare how');
AddLine('fast (or slow) your adapter is to real CGA.');
AddLine('');
SetOption(1,cstring,67,Finished);
SetOption(2,astring,65,Escaped);
Result:=Show;
Done;
end;
if Result=Escaped then exit;
PrepTest;
asm
mov ax,$b800
mov es,ax
xor di,di
mov cx,BlockSize
shr cx,1
mov ax,$0F00 {black back, white fore, 00 char}
cld
call _PZTimerOn
rep stosw
call _PZTimerOff
end;
ReportSpeed('Writing',BlockSize,'bytes of your video adapter RAM took',
'Your video RAM''s write speed is',340);
PostTest;
end;
Procedure BenchReadSpeedOpcodes;
const
BlockSize=$1000;
begin
with InfoPrompt do begin
init(6,strpas(menuLookup[mOARB].title));
WinForm^.vWinPtr^.SetColors(descBorder,descBody,descTitle,descIcons);
AddLine('');
AddLine('This benchmarks your video adapter RAM''s read speed');
AddLine('with CPU no-op instructions interleaved with memory');
AddLine('accesses. This can be used to test if CPU caching');
AddLine('and/or bus speed affects the speed of video adapter RAM.');
AddLine('');
SetOption(1,cstring,67,Finished);
SetOption(2,astring,65,Escaped);
Result:=Show;
Done;
end;
if Result=Escaped then exit;
PrepTest;
asm
push ds
mov ax,$b800
mov ds,ax
xor si,si
cld
mov cx,BlockSize
shr cx,1
shr cx,1
shr cx,1
shr cx,1
call _PZTimerOn
@loopit: {unrolled a bit, so that the flush at JMP time doesn't totally cripple us}
lodsb;nop;lodsb;nop;lodsb;nop;lodsb;nop;
lodsb;nop;lodsb;nop;lodsb;nop;lodsb;nop;
lodsb;nop;lodsb;nop;lodsb;nop;lodsb;nop;
lodsb;nop;lodsb;nop;lodsb;nop;lodsb;nop;
loop @loopit
call _PZTimerOff
pop ds
end;
ReportSpeed('Reading',BlockSize,'bytes of video RAM mixed with NOPs took',
'This means our interleaved read speed was',199);
PostTest;
end;
Procedure BenchWriteSpeedOpcodes;
const
BlockSize=$1000;
begin
with InfoPrompt do begin
init(6,strpas(menuLookup[mOAWB].title));
WinForm^.vWinPtr^.SetColors(descBorder,descBody,descTitle,descIcons);
AddLine('');
AddLine('This benchmarks your video adapter RAM''s write speed');
AddLine('with CPU no-op instructions interleaved with memory');
AddLine('accesses. This can be used to test if CPU caching');
AddLine('and/or bus speed affects the speed of video adapter RAM.');
AddLine('');
SetOption(1,cstring,67,Finished);
SetOption(2,astring,65,Escaped);
Result:=Show;
Done;
end;
if Result=Escaped then exit;
PrepTest;
asm
mov ax,$b800
mov es,ax
xor di,di
cld
mov cx,BlockSize
shr cx,1
shr cx,1
shr cx,1
shr cx,1
xor al,al
call _PZTimerOn
@loopit: {unrolled a bit, so that the flush at JMP time doesn't totally cripple us}
stosb;nop;stosb;nop;stosb;nop;stosb;nop;
stosb;nop;stosb;nop;stosb;nop;stosb;nop;
stosb;nop;stosb;nop;stosb;nop;stosb;nop;
stosb;nop;stosb;nop;stosb;nop;stosb;nop;
loop @loopit
call _PZTimerOff
end;
Screen.Clear(TWhite,' '); {repaint the screen since we just trashed it}
ReportSpeed('Writing',BlockSize,'bytes of video RAM mixed with NOPs took',
'This means our interleaved write speed was',194);
PostTest;
end;
end.