summaryrefslogtreecommitdiff
path: root/contrib/vstudio/vc7
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2011-09-09 23:22:37 -0700
committerMark Adler <madler@alumni.caltech.edu>2011-09-09 23:22:37 -0700
commit4b5a43a219d51066c01ff2ab86af18b967f2d0dd (patch)
tree4dcaf0cd18751d04cf638a9a6ec521990d4f2e90 /contrib/vstudio/vc7
parent086e982175da84b3db958191031380794315f95f (diff)
downloadzlib-1.2.0.5.tar.gz
zlib-1.2.0.5.tar.bz2
zlib-1.2.0.5.zip
zlib 1.2.0.5v1.2.0.5
Diffstat (limited to '')
-rw-r--r--contrib/masmx86/gvmat32.asm (renamed from contrib/vstudio/vc70_32/gvmat32.asm)1810
-rw-r--r--contrib/masmx86/gvmat32c.c (renamed from contrib/vstudio/vc70_32/gvmat32c.c)415
-rw-r--r--contrib/vstudio/vc7/gvmat32.obj (renamed from contrib/vstudio/vc70_32/gvmat32.obj)bin10143 -> 10143 bytes
-rw-r--r--contrib/vstudio/vc7/inffas32.objbin0 -> 14899 bytes
-rw-r--r--contrib/vstudio/vc7/miniunz.vcproj (renamed from contrib/vstudio/vc70_32/miniunz.vcproj)6
-rw-r--r--contrib/vstudio/vc7/minizip.vcproj (renamed from contrib/vstudio/vc70_32/minizip.vcproj)6
-rw-r--r--contrib/vstudio/vc7/zlib.rc (renamed from contrib/vstudio/vc70_32/zlib.rc)0
-rw-r--r--contrib/vstudio/vc7/zlibstat.vcproj (renamed from contrib/vstudio/vc70_32/zlibstat.vcproj)21
-rw-r--r--contrib/vstudio/vc7/zlibvc.def (renamed from contrib/vstudio/vc70_32/zlibvc.def)5
-rw-r--r--contrib/vstudio/vc7/zlibvc.sln (renamed from contrib/vstudio/vc70_32/zlibvc.sln)0
-rw-r--r--contrib/vstudio/vc7/zlibvc.vcproj (renamed from contrib/vstudio/vc70_32/zlibvc.vcproj)66
-rw-r--r--contrib/vstudio/vc70_32/inffastAsm.asm1020
-rw-r--r--contrib/vstudio/vc70_32/inffastAsm.objbin14895 -> 0 bytes
-rw-r--r--contrib/vstudio/vc70_32/mkgvmt32.bat2
14 files changed, 1153 insertions, 2198 deletions
diff --git a/contrib/vstudio/vc70_32/gvmat32.asm b/contrib/masmx86/gvmat32.asm
index 320348f..ec360e6 100644
--- a/contrib/vstudio/vc70_32/gvmat32.asm
+++ b/contrib/masmx86/gvmat32.asm
@@ -1,905 +1,905 @@
1; 1;
2; gvmat32.asm -- Asm portion of the optimized longest_match for 32 bits x86 2; gvmat32.asm -- Asm portion of the optimized longest_match for 32 bits x86
3; Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant. 3; Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant.
4; File written by Gilles Vollant, by modifiying the longest_match 4; File written by Gilles Vollant, by modifiying the longest_match
5; from Jean-loup Gailly in deflate.c 5; from Jean-loup Gailly in deflate.c
6; It need wmask == 0x7fff 6; It need wmask == 0x7fff
7; (assembly code is faster with a fixed wmask) 7; (assembly code is faster with a fixed wmask)
8; 8;
9; For Visual C++ 4.2 and ML 6.11c (version in directory \MASM611C of Win95 DDK) 9; For Visual C++ 4.2 and ML 6.11c (version in directory \MASM611C of Win95 DDK)
10; I compile with : "ml /coff /Zi /c gvmat32.asm" 10; I compile with : "ml /coff /Zi /c gvmat32.asm"
11; 11;
12 12
13;uInt longest_match_7fff(s, cur_match) 13;uInt longest_match_7fff(s, cur_match)
14; deflate_state *s; 14; deflate_state *s;
15; IPos cur_match; /* current match */ 15; IPos cur_match; /* current match */
16 16
17 NbStack equ 76 17 NbStack equ 76
18 cur_match equ dword ptr[esp+NbStack-0] 18 cur_match equ dword ptr[esp+NbStack-0]
19 str_s equ dword ptr[esp+NbStack-4] 19 str_s equ dword ptr[esp+NbStack-4]
20; 5 dword on top (ret,ebp,esi,edi,ebx) 20; 5 dword on top (ret,ebp,esi,edi,ebx)
21 adrret equ dword ptr[esp+NbStack-8] 21 adrret equ dword ptr[esp+NbStack-8]
22 pushebp equ dword ptr[esp+NbStack-12] 22 pushebp equ dword ptr[esp+NbStack-12]
23 pushedi equ dword ptr[esp+NbStack-16] 23 pushedi equ dword ptr[esp+NbStack-16]
24 pushesi equ dword ptr[esp+NbStack-20] 24 pushesi equ dword ptr[esp+NbStack-20]
25 pushebx equ dword ptr[esp+NbStack-24] 25 pushebx equ dword ptr[esp+NbStack-24]
26 26
27 chain_length equ dword ptr [esp+NbStack-28] 27 chain_length equ dword ptr [esp+NbStack-28]
28 limit equ dword ptr [esp+NbStack-32] 28 limit equ dword ptr [esp+NbStack-32]
29 best_len equ dword ptr [esp+NbStack-36] 29 best_len equ dword ptr [esp+NbStack-36]
30 window equ dword ptr [esp+NbStack-40] 30 window equ dword ptr [esp+NbStack-40]
31 prev equ dword ptr [esp+NbStack-44] 31 prev equ dword ptr [esp+NbStack-44]
32 scan_start equ word ptr [esp+NbStack-48] 32 scan_start equ word ptr [esp+NbStack-48]
33 wmask equ dword ptr [esp+NbStack-52] 33 wmask equ dword ptr [esp+NbStack-52]
34 match_start_ptr equ dword ptr [esp+NbStack-56] 34 match_start_ptr equ dword ptr [esp+NbStack-56]
35 nice_match equ dword ptr [esp+NbStack-60] 35 nice_match equ dword ptr [esp+NbStack-60]
36 scan equ dword ptr [esp+NbStack-64] 36 scan equ dword ptr [esp+NbStack-64]
37 37
38 windowlen equ dword ptr [esp+NbStack-68] 38 windowlen equ dword ptr [esp+NbStack-68]
39 match_start equ dword ptr [esp+NbStack-72] 39 match_start equ dword ptr [esp+NbStack-72]
40 strend equ dword ptr [esp+NbStack-76] 40 strend equ dword ptr [esp+NbStack-76]
41 NbStackAdd equ (NbStack-24) 41 NbStackAdd equ (NbStack-24)
42 42
43 .386p 43 .386p
44 44
45 name gvmatch 45 name gvmatch
46 .MODEL FLAT 46 .MODEL FLAT
47 47
48 48
49 49
50; all the +4 offsets are due to the addition of pending_buf_size (in zlib 50; all the +4 offsets are due to the addition of pending_buf_size (in zlib
51; in the deflate_state structure since the asm code was first written 51; in the deflate_state structure since the asm code was first written
52; (if you compile with zlib 1.0.4 or older, remove the +4). 52; (if you compile with zlib 1.0.4 or older, remove the +4).
53; Note : these value are good with a 8 bytes boundary pack structure 53; Note : these value are good with a 8 bytes boundary pack structure
54 dep_chain_length equ 70h+4 54 dep_chain_length equ 70h+4
55 dep_window equ 2ch+4 55 dep_window equ 2ch+4
56 dep_strstart equ 60h+4 56 dep_strstart equ 60h+4
57 dep_prev_length equ 6ch+4 57 dep_prev_length equ 6ch+4
58 dep_nice_match equ 84h+4 58 dep_nice_match equ 84h+4
59 dep_w_size equ 20h+4 59 dep_w_size equ 20h+4
60 dep_prev equ 34h+4 60 dep_prev equ 34h+4
61 dep_w_mask equ 28h+4 61 dep_w_mask equ 28h+4
62 dep_good_match equ 80h+4 62 dep_good_match equ 80h+4
63 dep_match_start equ 64h+4 63 dep_match_start equ 64h+4
64 dep_lookahead equ 68h+4 64 dep_lookahead equ 68h+4
65 65
66 66
67_TEXT segment 67_TEXT segment
68 68
69IFDEF NOUNDERLINE 69IFDEF NOUNDERLINE
70 public longest_match_7fff 70 public longest_match_7fff
71 public longest_match_686 71 public longest_match_686
72; public match_init 72; public match_init
73ELSE 73ELSE
74 public _longest_match_7fff 74 public _longest_match_7fff
75 public _longest_match_686 75 public _longest_match_686
76; public _match_init 76; public _match_init
77ENDIF 77ENDIF
78 78
79 MAX_MATCH equ 258 79 MAX_MATCH equ 258
80 MIN_MATCH equ 3 80 MIN_MATCH equ 3
81 MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1) 81 MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1)
82 82
83 83
84 84
85IFDEF NOUNDERLINE 85IFDEF NOUNDERLINE
86;match_init proc near 86;match_init proc near
87; ret 87; ret
88;match_init endp 88;match_init endp
89ELSE 89ELSE
90;_match_init proc near 90;_match_init proc near
91; ret 91; ret
92;_match_init endp 92;_match_init endp
93ENDIF 93ENDIF
94 94
95 95
96IFDEF NOUNDERLINE 96IFDEF NOUNDERLINE
97longest_match_7fff proc near 97longest_match_7fff proc near
98ELSE 98ELSE
99_longest_match_7fff proc near 99_longest_match_7fff proc near
100ENDIF 100ENDIF
101 101
102 mov edx,[esp+4] 102 mov edx,[esp+4]
103 103
104 104
105 105
106 push ebp 106 push ebp
107 push edi 107 push edi
108 push esi 108 push esi
109 push ebx 109 push ebx
110 110
111 sub esp,NbStackAdd 111 sub esp,NbStackAdd
112 112
113; initialize or check the variables used in match.asm. 113; initialize or check the variables used in match.asm.
114 mov ebp,edx 114 mov ebp,edx
115 115
116; chain_length = s->max_chain_length 116; chain_length = s->max_chain_length
117; if (prev_length>=good_match) chain_length >>= 2 117; if (prev_length>=good_match) chain_length >>= 2
118 mov edx,[ebp+dep_chain_length] 118 mov edx,[ebp+dep_chain_length]
119 mov ebx,[ebp+dep_prev_length] 119 mov ebx,[ebp+dep_prev_length]
120 cmp [ebp+dep_good_match],ebx 120 cmp [ebp+dep_good_match],ebx
121 ja noshr 121 ja noshr
122 shr edx,2 122 shr edx,2
123noshr: 123noshr:
124; we increment chain_length because in the asm, the --chain_lenght is in the beginning of the loop 124; we increment chain_length because in the asm, the --chain_lenght is in the beginning of the loop
125 inc edx 125 inc edx
126 mov edi,[ebp+dep_nice_match] 126 mov edi,[ebp+dep_nice_match]
127 mov chain_length,edx 127 mov chain_length,edx
128 mov eax,[ebp+dep_lookahead] 128 mov eax,[ebp+dep_lookahead]
129 cmp eax,edi 129 cmp eax,edi
130; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; 130; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
131 jae nolookaheadnicematch 131 jae nolookaheadnicematch
132 mov edi,eax 132 mov edi,eax
133nolookaheadnicematch: 133nolookaheadnicematch:
134; best_len = s->prev_length 134; best_len = s->prev_length
135 mov best_len,ebx 135 mov best_len,ebx
136 136
137; window = s->window 137; window = s->window
138 mov esi,[ebp+dep_window] 138 mov esi,[ebp+dep_window]
139 mov ecx,[ebp+dep_strstart] 139 mov ecx,[ebp+dep_strstart]
140 mov window,esi 140 mov window,esi
141 141
142 mov nice_match,edi 142 mov nice_match,edi
143; scan = window + strstart 143; scan = window + strstart
144 add esi,ecx 144 add esi,ecx
145 mov scan,esi 145 mov scan,esi
146; dx = *window 146; dx = *window
147 mov dx,word ptr [esi] 147 mov dx,word ptr [esi]
148; bx = *(window+best_len-1) 148; bx = *(window+best_len-1)
149 mov bx,word ptr [esi+ebx-1] 149 mov bx,word ptr [esi+ebx-1]
150 add esi,MAX_MATCH-1 150 add esi,MAX_MATCH-1
151; scan_start = *scan 151; scan_start = *scan
152 mov scan_start,dx 152 mov scan_start,dx
153; strend = scan + MAX_MATCH-1 153; strend = scan + MAX_MATCH-1
154 mov strend,esi 154 mov strend,esi
155; bx = scan_end = *(window+best_len-1) 155; bx = scan_end = *(window+best_len-1)
156 156
157; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? 157; IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
158; s->strstart - (IPos)MAX_DIST(s) : NIL; 158; s->strstart - (IPos)MAX_DIST(s) : NIL;
159 159
160 mov esi,[ebp+dep_w_size] 160 mov esi,[ebp+dep_w_size]
161 sub esi,MIN_LOOKAHEAD 161 sub esi,MIN_LOOKAHEAD
162; here esi = MAX_DIST(s) 162; here esi = MAX_DIST(s)
163 sub ecx,esi 163 sub ecx,esi
164 ja nodist 164 ja nodist
165 xor ecx,ecx 165 xor ecx,ecx
166nodist: 166nodist:
167 mov limit,ecx 167 mov limit,ecx
168 168
169; prev = s->prev 169; prev = s->prev
170 mov edx,[ebp+dep_prev] 170 mov edx,[ebp+dep_prev]
171 mov prev,edx 171 mov prev,edx
172 172
173; 173;
174 mov edx,dword ptr [ebp+dep_match_start] 174 mov edx,dword ptr [ebp+dep_match_start]
175 mov bp,scan_start 175 mov bp,scan_start
176 mov eax,cur_match 176 mov eax,cur_match
177 mov match_start,edx 177 mov match_start,edx
178 178
179 mov edx,window 179 mov edx,window
180 mov edi,edx 180 mov edi,edx
181 add edi,best_len 181 add edi,best_len
182 mov esi,prev 182 mov esi,prev
183 dec edi 183 dec edi
184; windowlen = window + best_len -1 184; windowlen = window + best_len -1
185 mov windowlen,edi 185 mov windowlen,edi
186 186
187 jmp beginloop2 187 jmp beginloop2
188 align 4 188 align 4
189 189
190; here, in the loop 190; here, in the loop
191; eax = ax = cur_match 191; eax = ax = cur_match
192; ecx = limit 192; ecx = limit
193; bx = scan_end 193; bx = scan_end
194; bp = scan_start 194; bp = scan_start
195; edi = windowlen (window + best_len -1) 195; edi = windowlen (window + best_len -1)
196; esi = prev 196; esi = prev
197 197
198 198
199;// here; chain_length <=16 199;// here; chain_length <=16
200normalbeg0add16: 200normalbeg0add16:
201 add chain_length,16 201 add chain_length,16
202 jz exitloop 202 jz exitloop
203normalbeg0: 203normalbeg0:
204 cmp word ptr[edi+eax],bx 204 cmp word ptr[edi+eax],bx
205 je normalbeg2noroll 205 je normalbeg2noroll
206rcontlabnoroll: 206rcontlabnoroll:
207; cur_match = prev[cur_match & wmask] 207; cur_match = prev[cur_match & wmask]
208 and eax,7fffh 208 and eax,7fffh
209 mov ax,word ptr[esi+eax*2] 209 mov ax,word ptr[esi+eax*2]
210; if cur_match > limit, go to exitloop 210; if cur_match > limit, go to exitloop
211 cmp ecx,eax 211 cmp ecx,eax
212 jnb exitloop 212 jnb exitloop
213; if --chain_length != 0, go to exitloop 213; if --chain_length != 0, go to exitloop
214 dec chain_length 214 dec chain_length
215 jnz normalbeg0 215 jnz normalbeg0
216 jmp exitloop 216 jmp exitloop
217 217
218normalbeg2noroll: 218normalbeg2noroll:
219; if (scan_start==*(cur_match+window)) goto normalbeg2 219; if (scan_start==*(cur_match+window)) goto normalbeg2
220 cmp bp,word ptr[edx+eax] 220 cmp bp,word ptr[edx+eax]
221 jne rcontlabnoroll 221 jne rcontlabnoroll
222 jmp normalbeg2 222 jmp normalbeg2
223 223
224contloop3: 224contloop3:
225 mov edi,windowlen 225 mov edi,windowlen
226 226
227; cur_match = prev[cur_match & wmask] 227; cur_match = prev[cur_match & wmask]
228 and eax,7fffh 228 and eax,7fffh
229 mov ax,word ptr[esi+eax*2] 229 mov ax,word ptr[esi+eax*2]
230; if cur_match > limit, go to exitloop 230; if cur_match > limit, go to exitloop
231 cmp ecx,eax 231 cmp ecx,eax
232jnbexitloopshort1: 232jnbexitloopshort1:
233 jnb exitloop 233 jnb exitloop
234; if --chain_length != 0, go to exitloop 234; if --chain_length != 0, go to exitloop
235 235
236 236
237; begin the main loop 237; begin the main loop
238beginloop2: 238beginloop2:
239 sub chain_length,16+1 239 sub chain_length,16+1
240; if chain_length <=16, don't use the unrolled loop 240; if chain_length <=16, don't use the unrolled loop
241 jna normalbeg0add16 241 jna normalbeg0add16
242 242
243do16: 243do16:
244 cmp word ptr[edi+eax],bx 244 cmp word ptr[edi+eax],bx
245 je normalbeg2dc0 245 je normalbeg2dc0
246 246
247maccn MACRO lab 247maccn MACRO lab
248 and eax,7fffh 248 and eax,7fffh
249 mov ax,word ptr[esi+eax*2] 249 mov ax,word ptr[esi+eax*2]
250 cmp ecx,eax 250 cmp ecx,eax
251 jnb exitloop 251 jnb exitloop
252 cmp word ptr[edi+eax],bx 252 cmp word ptr[edi+eax],bx
253 je lab 253 je lab
254 ENDM 254 ENDM
255 255
256rcontloop0: 256rcontloop0:
257 maccn normalbeg2dc1 257 maccn normalbeg2dc1
258 258
259rcontloop1: 259rcontloop1:
260 maccn normalbeg2dc2 260 maccn normalbeg2dc2
261 261
262rcontloop2: 262rcontloop2:
263 maccn normalbeg2dc3 263 maccn normalbeg2dc3
264 264
265rcontloop3: 265rcontloop3:
266 maccn normalbeg2dc4 266 maccn normalbeg2dc4
267 267
268rcontloop4: 268rcontloop4:
269 maccn normalbeg2dc5 269 maccn normalbeg2dc5
270 270
271rcontloop5: 271rcontloop5:
272 maccn normalbeg2dc6 272 maccn normalbeg2dc6
273 273
274rcontloop6: 274rcontloop6:
275 maccn normalbeg2dc7 275 maccn normalbeg2dc7
276 276
277rcontloop7: 277rcontloop7:
278 maccn normalbeg2dc8 278 maccn normalbeg2dc8
279 279
280rcontloop8: 280rcontloop8:
281 maccn normalbeg2dc9 281 maccn normalbeg2dc9
282 282
283rcontloop9: 283rcontloop9:
284 maccn normalbeg2dc10 284 maccn normalbeg2dc10
285 285
286rcontloop10: 286rcontloop10:
287 maccn short normalbeg2dc11 287 maccn short normalbeg2dc11
288 288
289rcontloop11: 289rcontloop11:
290 maccn short normalbeg2dc12 290 maccn short normalbeg2dc12
291 291
292rcontloop12: 292rcontloop12:
293 maccn short normalbeg2dc13 293 maccn short normalbeg2dc13
294 294
295rcontloop13: 295rcontloop13:
296 maccn short normalbeg2dc14 296 maccn short normalbeg2dc14
297 297
298rcontloop14: 298rcontloop14:
299 maccn short normalbeg2dc15 299 maccn short normalbeg2dc15
300 300
301rcontloop15: 301rcontloop15:
302 and eax,7fffh 302 and eax,7fffh
303 mov ax,word ptr[esi+eax*2] 303 mov ax,word ptr[esi+eax*2]
304 cmp ecx,eax 304 cmp ecx,eax
305 jnb exitloop 305 jnb exitloop
306 306
307 sub chain_length,16 307 sub chain_length,16
308 ja do16 308 ja do16
309 jmp normalbeg0add16 309 jmp normalbeg0add16
310 310
311;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 311;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
312 312
313normbeg MACRO rcontlab,valsub 313normbeg MACRO rcontlab,valsub
314; if we are here, we know that *(match+best_len-1) == scan_end 314; if we are here, we know that *(match+best_len-1) == scan_end
315 cmp bp,word ptr[edx+eax] 315 cmp bp,word ptr[edx+eax]
316; if (match != scan_start) goto rcontlab 316; if (match != scan_start) goto rcontlab
317 jne rcontlab 317 jne rcontlab
318; calculate the good chain_length, and we'll compare scan and match string 318; calculate the good chain_length, and we'll compare scan and match string
319 add chain_length,16-valsub 319 add chain_length,16-valsub
320 jmp iseq 320 jmp iseq
321 ENDM 321 ENDM
322 322
323 323
324normalbeg2dc11: 324normalbeg2dc11:
325 normbeg rcontloop11,11 325 normbeg rcontloop11,11
326 326
327normalbeg2dc12: 327normalbeg2dc12:
328 normbeg short rcontloop12,12 328 normbeg short rcontloop12,12
329 329
330normalbeg2dc13: 330normalbeg2dc13:
331 normbeg short rcontloop13,13 331 normbeg short rcontloop13,13
332 332
333normalbeg2dc14: 333normalbeg2dc14:
334 normbeg short rcontloop14,14 334 normbeg short rcontloop14,14
335 335
336normalbeg2dc15: 336normalbeg2dc15:
337 normbeg short rcontloop15,15 337 normbeg short rcontloop15,15
338 338
339normalbeg2dc10: 339normalbeg2dc10:
340 normbeg rcontloop10,10 340 normbeg rcontloop10,10
341 341
342normalbeg2dc9: 342normalbeg2dc9:
343 normbeg rcontloop9,9 343 normbeg rcontloop9,9
344 344
345normalbeg2dc8: 345normalbeg2dc8:
346 normbeg rcontloop8,8 346 normbeg rcontloop8,8
347 347
348normalbeg2dc7: 348normalbeg2dc7:
349 normbeg rcontloop7,7 349 normbeg rcontloop7,7
350 350
351normalbeg2dc6: 351normalbeg2dc6:
352 normbeg rcontloop6,6 352 normbeg rcontloop6,6
353 353
354normalbeg2dc5: 354normalbeg2dc5:
355 normbeg rcontloop5,5 355 normbeg rcontloop5,5
356 356
357normalbeg2dc4: 357normalbeg2dc4:
358 normbeg rcontloop4,4 358 normbeg rcontloop4,4
359 359
360normalbeg2dc3: 360normalbeg2dc3:
361 normbeg rcontloop3,3 361 normbeg rcontloop3,3
362 362
363normalbeg2dc2: 363normalbeg2dc2:
364 normbeg rcontloop2,2 364 normbeg rcontloop2,2
365 365
366normalbeg2dc1: 366normalbeg2dc1:
367 normbeg rcontloop1,1 367 normbeg rcontloop1,1
368 368
369normalbeg2dc0: 369normalbeg2dc0:
370 normbeg rcontloop0,0 370 normbeg rcontloop0,0
371 371
372 372
373; we go in normalbeg2 because *(ushf*)(match+best_len-1) == scan_end 373; we go in normalbeg2 because *(ushf*)(match+best_len-1) == scan_end
374 374
375normalbeg2: 375normalbeg2:
376 mov edi,window 376 mov edi,window
377 377
378 cmp bp,word ptr[edi+eax] 378 cmp bp,word ptr[edi+eax]
379 jne contloop3 ; if *(ushf*)match != scan_start, continue 379 jne contloop3 ; if *(ushf*)match != scan_start, continue
380 380
381iseq: 381iseq:
382; if we are here, we know that *(match+best_len-1) == scan_end 382; if we are here, we know that *(match+best_len-1) == scan_end
383; and (match == scan_start) 383; and (match == scan_start)
384 384
385 mov edi,edx 385 mov edi,edx
386 mov esi,scan ; esi = scan 386 mov esi,scan ; esi = scan
387 add edi,eax ; edi = window + cur_match = match 387 add edi,eax ; edi = window + cur_match = match
388 388
389 mov edx,[esi+3] ; compare manually dword at match+3 389 mov edx,[esi+3] ; compare manually dword at match+3
390 xor edx,[edi+3] ; and scan +3 390 xor edx,[edi+3] ; and scan +3
391 391
392 jz begincompare ; if equal, go to long compare 392 jz begincompare ; if equal, go to long compare
393 393
394; we will determine the unmatch byte and calculate len (in esi) 394; we will determine the unmatch byte and calculate len (in esi)
395 or dl,dl 395 or dl,dl
396 je eq1rr 396 je eq1rr
397 mov esi,3 397 mov esi,3
398 jmp trfinval 398 jmp trfinval
399eq1rr: 399eq1rr:
400 or dx,dx 400 or dx,dx
401 je eq1 401 je eq1
402 402
403 mov esi,4 403 mov esi,4
404 jmp trfinval 404 jmp trfinval
405eq1: 405eq1:
406 and edx,0ffffffh 406 and edx,0ffffffh
407 jz eq11 407 jz eq11
408 mov esi,5 408 mov esi,5
409 jmp trfinval 409 jmp trfinval
410eq11: 410eq11:
411 mov esi,6 411 mov esi,6
412 jmp trfinval 412 jmp trfinval
413 413
414begincompare: 414begincompare:
415 ; here we now scan and match begin same 415 ; here we now scan and match begin same
416 add edi,6 416 add edi,6
417 add esi,6 417 add esi,6
418 mov ecx,(MAX_MATCH-(2+4))/4 ; scan for at most MAX_MATCH bytes 418 mov ecx,(MAX_MATCH-(2+4))/4 ; scan for at most MAX_MATCH bytes
419 repe cmpsd ; loop until mismatch 419 repe cmpsd ; loop until mismatch
420 420
421 je trfin ; go to trfin if not unmatch 421 je trfin ; go to trfin if not unmatch
422; we determine the unmatch byte 422; we determine the unmatch byte
423 sub esi,4 423 sub esi,4
424 mov edx,[edi-4] 424 mov edx,[edi-4]
425 xor edx,[esi] 425 xor edx,[esi]
426 426
427 or dl,dl 427 or dl,dl
428 jnz trfin 428 jnz trfin
429 inc esi 429 inc esi
430 430
431 or dx,dx 431 or dx,dx
432 jnz trfin 432 jnz trfin
433 inc esi 433 inc esi
434 434
435 and edx,0ffffffh 435 and edx,0ffffffh
436 jnz trfin 436 jnz trfin
437 inc esi 437 inc esi
438 438
439trfin: 439trfin:
440 sub esi,scan ; esi = len 440 sub esi,scan ; esi = len
441trfinval: 441trfinval:
442; here we have finised compare, and esi contain len of equal string 442; here we have finised compare, and esi contain len of equal string
443 cmp esi,best_len ; if len > best_len, go newbestlen 443 cmp esi,best_len ; if len > best_len, go newbestlen
444 ja short newbestlen 444 ja short newbestlen
445; now we restore edx, ecx and esi, for the big loop 445; now we restore edx, ecx and esi, for the big loop
446 mov esi,prev 446 mov esi,prev
447 mov ecx,limit 447 mov ecx,limit
448 mov edx,window 448 mov edx,window
449 jmp contloop3 449 jmp contloop3
450 450
451newbestlen: 451newbestlen:
452 mov best_len,esi ; len become best_len 452 mov best_len,esi ; len become best_len
453 453
454 mov match_start,eax ; save new position as match_start 454 mov match_start,eax ; save new position as match_start
455 cmp esi,nice_match ; if best_len >= nice_match, exit 455 cmp esi,nice_match ; if best_len >= nice_match, exit
456 jae exitloop 456 jae exitloop
457 mov ecx,scan 457 mov ecx,scan
458 mov edx,window ; restore edx=window 458 mov edx,window ; restore edx=window
459 add ecx,esi 459 add ecx,esi
460 add esi,edx 460 add esi,edx
461 461
462 dec esi 462 dec esi
463 mov windowlen,esi ; windowlen = window + best_len-1 463 mov windowlen,esi ; windowlen = window + best_len-1
464 mov bx,[ecx-1] ; bx = *(scan+best_len-1) = scan_end 464 mov bx,[ecx-1] ; bx = *(scan+best_len-1) = scan_end
465 465
466; now we restore ecx and esi, for the big loop : 466; now we restore ecx and esi, for the big loop :
467 mov esi,prev 467 mov esi,prev
468 mov ecx,limit 468 mov ecx,limit
469 jmp contloop3 469 jmp contloop3
470 470
471exitloop: 471exitloop:
472; exit : s->match_start=match_start 472; exit : s->match_start=match_start
473 mov ebx,match_start 473 mov ebx,match_start
474 mov ebp,str_s 474 mov ebp,str_s
475 mov ecx,best_len 475 mov ecx,best_len
476 mov dword ptr [ebp+dep_match_start],ebx 476 mov dword ptr [ebp+dep_match_start],ebx
477 mov eax,dword ptr [ebp+dep_lookahead] 477 mov eax,dword ptr [ebp+dep_lookahead]
478 cmp ecx,eax 478 cmp ecx,eax
479 ja minexlo 479 ja minexlo
480 mov eax,ecx 480 mov eax,ecx
481minexlo: 481minexlo:
482; return min(best_len,s->lookahead) 482; return min(best_len,s->lookahead)
483 483
484; restore stack and register ebx,esi,edi,ebp 484; restore stack and register ebx,esi,edi,ebp
485 add esp,NbStackAdd 485 add esp,NbStackAdd
486 486
487 pop ebx 487 pop ebx
488 pop esi 488 pop esi
489 pop edi 489 pop edi
490 pop ebp 490 pop ebp
491 ret 491 ret
492InfoAuthor: 492InfoAuthor:
493; please don't remove this string ! 493; please don't remove this string !
494; Your are free use gvmat32 in any fre or commercial apps if you don't remove the string in the binary! 494; Your are free use gvmat32 in any fre or commercial apps if you don't remove the string in the binary!
495 db 0dh,0ah,"GVMat32 optimised assembly code written 1996-98 by Gilles Vollant",0dh,0ah 495 db 0dh,0ah,"GVMat32 optimised assembly code written 1996-98 by Gilles Vollant",0dh,0ah
496 496
497 497
498 498
499IFDEF NOUNDERLINE 499IFDEF NOUNDERLINE
500longest_match_7fff endp 500longest_match_7fff endp
501ELSE 501ELSE
502_longest_match_7fff endp 502_longest_match_7fff endp
503ENDIF 503ENDIF
504 504
505 505
506IFDEF NOUNDERLINE 506IFDEF NOUNDERLINE
507cpudetect32 proc near 507cpudetect32 proc near
508ELSE 508ELSE
509_cpudetect32 proc near 509_cpudetect32 proc near
510ENDIF 510ENDIF
511 511
512 push ebx 512 push ebx
513 513
514 pushfd ; push original EFLAGS 514 pushfd ; push original EFLAGS
515 pop eax ; get original EFLAGS 515 pop eax ; get original EFLAGS
516 mov ecx, eax ; save original EFLAGS 516 mov ecx, eax ; save original EFLAGS
517 xor eax, 40000h ; flip AC bit in EFLAGS 517 xor eax, 40000h ; flip AC bit in EFLAGS
518 push eax ; save new EFLAGS value on stack 518 push eax ; save new EFLAGS value on stack
519 popfd ; replace current EFLAGS value 519 popfd ; replace current EFLAGS value
520 pushfd ; get new EFLAGS 520 pushfd ; get new EFLAGS
521 pop eax ; store new EFLAGS in EAX 521 pop eax ; store new EFLAGS in EAX
522 xor eax, ecx ; can’t toggle AC bit, processor=80386 522 xor eax, ecx ; can’t toggle AC bit, processor=80386
523 jz end_cpu_is_386 ; jump if 80386 processor 523 jz end_cpu_is_386 ; jump if 80386 processor
524 push ecx 524 push ecx
525 popfd ; restore AC bit in EFLAGS first 525 popfd ; restore AC bit in EFLAGS first
526 526
527 pushfd 527 pushfd
528 pushfd 528 pushfd
529 pop ecx 529 pop ecx
530 530
531 mov eax, ecx ; get original EFLAGS 531 mov eax, ecx ; get original EFLAGS
532 xor eax, 200000h ; flip ID bit in EFLAGS 532 xor eax, 200000h ; flip ID bit in EFLAGS
533 push eax ; save new EFLAGS value on stack 533 push eax ; save new EFLAGS value on stack
534 popfd ; replace current EFLAGS value 534 popfd ; replace current EFLAGS value
535 pushfd ; get new EFLAGS 535 pushfd ; get new EFLAGS
536 pop eax ; store new EFLAGS in EAX 536 pop eax ; store new EFLAGS in EAX
537 popfd ; restore original EFLAGS 537 popfd ; restore original EFLAGS
538 xor eax, ecx ; can’t toggle ID bit, 538 xor eax, ecx ; can’t toggle ID bit,
539 je is_old_486 ; processor=old 539 je is_old_486 ; processor=old
540 540
541 mov eax,1 541 mov eax,1
542 db 0fh,0a2h ;CPUID 542 db 0fh,0a2h ;CPUID
543 543
544exitcpudetect: 544exitcpudetect:
545 pop ebx 545 pop ebx
546 ret 546 ret
547 547
548end_cpu_is_386: 548end_cpu_is_386:
549 mov eax,0300h 549 mov eax,0300h
550 jmp exitcpudetect 550 jmp exitcpudetect
551 551
552is_old_486: 552is_old_486:
553 mov eax,0400h 553 mov eax,0400h
554 jmp exitcpudetect 554 jmp exitcpudetect
555 555
556IFDEF NOUNDERLINE 556IFDEF NOUNDERLINE
557cpudetect32 endp 557cpudetect32 endp
558ELSE 558ELSE
559_cpudetect32 endp 559_cpudetect32 endp
560ENDIF 560ENDIF
561 561
562 562
563 563
564 564
565MAX_MATCH equ 258 565MAX_MATCH equ 258
566MIN_MATCH equ 3 566MIN_MATCH equ 3
567MIN_LOOKAHEAD equ (MAX_MATCH + MIN_MATCH + 1) 567MIN_LOOKAHEAD equ (MAX_MATCH + MIN_MATCH + 1)
568MAX_MATCH_8_ equ ((MAX_MATCH + 7) AND 0FFF0h) 568MAX_MATCH_8_ equ ((MAX_MATCH + 7) AND 0FFF0h)
569 569
570 570
571;;; stack frame offsets 571;;; stack frame offsets
572 572
573chainlenwmask equ esp + 0 ; high word: current chain len 573chainlenwmask equ esp + 0 ; high word: current chain len
574 ; low word: s->wmask 574 ; low word: s->wmask
575window equ esp + 4 ; local copy of s->window 575window equ esp + 4 ; local copy of s->window
576windowbestlen equ esp + 8 ; s->window + bestlen 576windowbestlen equ esp + 8 ; s->window + bestlen
577scanstart equ esp + 16 ; first two bytes of string 577scanstart equ esp + 16 ; first two bytes of string
578scanend equ esp + 12 ; last two bytes of string 578scanend equ esp + 12 ; last two bytes of string
579scanalign equ esp + 20 ; dword-misalignment of string 579scanalign equ esp + 20 ; dword-misalignment of string
580nicematch equ esp + 24 ; a good enough match size 580nicematch equ esp + 24 ; a good enough match size
581bestlen equ esp + 28 ; size of best match so far 581bestlen equ esp + 28 ; size of best match so far
582scan equ esp + 32 ; ptr to string wanting match 582scan equ esp + 32 ; ptr to string wanting match
583 583
584LocalVarsSize equ 36 584LocalVarsSize equ 36
585; saved ebx byte esp + 36 585; saved ebx byte esp + 36
586; saved edi byte esp + 40 586; saved edi byte esp + 40
587; saved esi byte esp + 44 587; saved esi byte esp + 44
588; saved ebp byte esp + 48 588; saved ebp byte esp + 48
589; return address byte esp + 52 589; return address byte esp + 52
590deflatestate equ esp + 56 ; the function arguments 590deflatestate equ esp + 56 ; the function arguments
591curmatch equ esp + 60 591curmatch equ esp + 60
592 592
593;;; Offsets for fields in the deflate_state structure. These numbers 593;;; Offsets for fields in the deflate_state structure. These numbers
594;;; are calculated from the definition of deflate_state, with the 594;;; are calculated from the definition of deflate_state, with the
595;;; assumption that the compiler will dword-align the fields. (Thus, 595;;; assumption that the compiler will dword-align the fields. (Thus,
596;;; changing the definition of deflate_state could easily cause this 596;;; changing the definition of deflate_state could easily cause this
597;;; program to crash horribly, without so much as a warning at 597;;; program to crash horribly, without so much as a warning at
598;;; compile time. Sigh.) 598;;; compile time. Sigh.)
599 599
600dsWSize equ 36 600dsWSize equ 36
601dsWMask equ 44 601dsWMask equ 44
602dsWindow equ 48 602dsWindow equ 48
603dsPrev equ 56 603dsPrev equ 56
604dsMatchLen equ 88 604dsMatchLen equ 88
605dsPrevMatch equ 92 605dsPrevMatch equ 92
606dsStrStart equ 100 606dsStrStart equ 100
607dsMatchStart equ 104 607dsMatchStart equ 104
608dsLookahead equ 108 608dsLookahead equ 108
609dsPrevLen equ 112 609dsPrevLen equ 112
610dsMaxChainLen equ 116 610dsMaxChainLen equ 116
611dsGoodMatch equ 132 611dsGoodMatch equ 132
612dsNiceMatch equ 136 612dsNiceMatch equ 136
613 613
614 614
615;;; match.asm -- Pentium-Pro-optimized version of longest_match() 615;;; match.asm -- Pentium-Pro-optimized version of longest_match()
616;;; Written for zlib 1.1.2 616;;; Written for zlib 1.1.2
617;;; Copyright (C) 1998 Brian Raiter <breadbox@muppetlabs.com> 617;;; Copyright (C) 1998 Brian Raiter <breadbox@muppetlabs.com>
618;;; You can look at http://www.muppetlabs.com/~breadbox/software/assembly.html 618;;; You can look at http://www.muppetlabs.com/~breadbox/software/assembly.html
619;;; 619;;;
620;;; This is free software; you can redistribute it and/or modify it 620;;; This is free software; you can redistribute it and/or modify it
621;;; under the terms of the GNU General Public License. 621;;; under the terms of the GNU General Public License.
622 622
623;GLOBAL _longest_match, _match_init 623;GLOBAL _longest_match, _match_init
624 624
625 625
626;SECTION .text 626;SECTION .text
627 627
628;;; uInt longest_match(deflate_state *deflatestate, IPos curmatch) 628;;; uInt longest_match(deflate_state *deflatestate, IPos curmatch)
629 629
630;_longest_match: 630;_longest_match:
631IFDEF NOUNDERLINE 631IFDEF NOUNDERLINE
632longest_match_686 proc near 632longest_match_686 proc near
633ELSE 633ELSE
634_longest_match_686 proc near 634_longest_match_686 proc near
635ENDIF 635ENDIF
636 636
637 637
638;;; Save registers that the compiler may be using, and adjust esp to 638;;; Save registers that the compiler may be using, and adjust esp to
639;;; make room for our stack frame. 639;;; make room for our stack frame.
640 640
641 push ebp 641 push ebp
642 push edi 642 push edi
643 push esi 643 push esi
644 push ebx 644 push ebx
645 sub esp, LocalVarsSize 645 sub esp, LocalVarsSize
646 646
647;;; Retrieve the function arguments. ecx will hold cur_match 647;;; Retrieve the function arguments. ecx will hold cur_match
648;;; throughout the entire function. edx will hold the pointer to the 648;;; throughout the entire function. edx will hold the pointer to the
649;;; deflate_state structure during the function's setup (before 649;;; deflate_state structure during the function's setup (before
650;;; entering the main loop. 650;;; entering the main loop.
651 651
652 mov edx, [deflatestate] 652 mov edx, [deflatestate]
653 mov ecx, [curmatch] 653 mov ecx, [curmatch]
654 654
655;;; uInt wmask = s->w_mask; 655;;; uInt wmask = s->w_mask;
656;;; unsigned chain_length = s->max_chain_length; 656;;; unsigned chain_length = s->max_chain_length;
657;;; if (s->prev_length >= s->good_match) { 657;;; if (s->prev_length >= s->good_match) {
658;;; chain_length >>= 2; 658;;; chain_length >>= 2;
659;;; } 659;;; }
660 660
661 mov eax, [edx + dsPrevLen] 661 mov eax, [edx + dsPrevLen]
662 mov ebx, [edx + dsGoodMatch] 662 mov ebx, [edx + dsGoodMatch]
663 cmp eax, ebx 663 cmp eax, ebx
664 mov eax, [edx + dsWMask] 664 mov eax, [edx + dsWMask]
665 mov ebx, [edx + dsMaxChainLen] 665 mov ebx, [edx + dsMaxChainLen]
666 jl LastMatchGood 666 jl LastMatchGood
667 shr ebx, 2 667 shr ebx, 2
668LastMatchGood: 668LastMatchGood:
669 669
670;;; chainlen is decremented once beforehand so that the function can 670;;; chainlen is decremented once beforehand so that the function can
671;;; use the sign flag instead of the zero flag for the exit test. 671;;; use the sign flag instead of the zero flag for the exit test.
672;;; It is then shifted into the high word, to make room for the wmask 672;;; It is then shifted into the high word, to make room for the wmask
673;;; value, which it will always accompany. 673;;; value, which it will always accompany.
674 674
675 dec ebx 675 dec ebx
676 shl ebx, 16 676 shl ebx, 16
677 or ebx, eax 677 or ebx, eax
678 mov [chainlenwmask], ebx 678 mov [chainlenwmask], ebx
679 679
680;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; 680;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
681 681
682 mov eax, [edx + dsNiceMatch] 682 mov eax, [edx + dsNiceMatch]
683 mov ebx, [edx + dsLookahead] 683 mov ebx, [edx + dsLookahead]
684 cmp ebx, eax 684 cmp ebx, eax
685 jl LookaheadLess 685 jl LookaheadLess
686 mov ebx, eax 686 mov ebx, eax
687LookaheadLess: mov [nicematch], ebx 687LookaheadLess: mov [nicematch], ebx
688 688
689;;; register Bytef *scan = s->window + s->strstart; 689;;; register Bytef *scan = s->window + s->strstart;
690 690
691 mov esi, [edx + dsWindow] 691 mov esi, [edx + dsWindow]
692 mov [window], esi 692 mov [window], esi
693 mov ebp, [edx + dsStrStart] 693 mov ebp, [edx + dsStrStart]
694 lea edi, [esi + ebp] 694 lea edi, [esi + ebp]
695 mov [scan], edi 695 mov [scan], edi
696 696
697;;; Determine how many bytes the scan ptr is off from being 697;;; Determine how many bytes the scan ptr is off from being
698;;; dword-aligned. 698;;; dword-aligned.
699 699
700 mov eax, edi 700 mov eax, edi
701 neg eax 701 neg eax
702 and eax, 3 702 and eax, 3
703 mov [scanalign], eax 703 mov [scanalign], eax
704 704
705;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? 705;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
706;;; s->strstart - (IPos)MAX_DIST(s) : NIL; 706;;; s->strstart - (IPos)MAX_DIST(s) : NIL;
707 707
708 mov eax, [edx + dsWSize] 708 mov eax, [edx + dsWSize]
709 sub eax, MIN_LOOKAHEAD 709 sub eax, MIN_LOOKAHEAD
710 sub ebp, eax 710 sub ebp, eax
711 jg LimitPositive 711 jg LimitPositive
712 xor ebp, ebp 712 xor ebp, ebp
713LimitPositive: 713LimitPositive:
714 714
715;;; int best_len = s->prev_length; 715;;; int best_len = s->prev_length;
716 716
717 mov eax, [edx + dsPrevLen] 717 mov eax, [edx + dsPrevLen]
718 mov [bestlen], eax 718 mov [bestlen], eax
719 719
720;;; Store the sum of s->window + best_len in esi locally, and in esi. 720;;; Store the sum of s->window + best_len in esi locally, and in esi.
721 721
722 add esi, eax 722 add esi, eax
723 mov [windowbestlen], esi 723 mov [windowbestlen], esi
724 724
725;;; register ush scan_start = *(ushf*)scan; 725;;; register ush scan_start = *(ushf*)scan;
726;;; register ush scan_end = *(ushf*)(scan+best_len-1); 726;;; register ush scan_end = *(ushf*)(scan+best_len-1);
727;;; Posf *prev = s->prev; 727;;; Posf *prev = s->prev;
728 728
729 movzx ebx, word ptr [edi] 729 movzx ebx, word ptr [edi]
730 mov [scanstart], ebx 730 mov [scanstart], ebx
731 movzx ebx, word ptr [edi + eax - 1] 731 movzx ebx, word ptr [edi + eax - 1]
732 mov [scanend], ebx 732 mov [scanend], ebx
733 mov edi, [edx + dsPrev] 733 mov edi, [edx + dsPrev]
734 734
735;;; Jump into the main loop. 735;;; Jump into the main loop.
736 736
737 mov edx, [chainlenwmask] 737 mov edx, [chainlenwmask]
738 jmp short LoopEntry 738 jmp short LoopEntry
739 739
740align 4 740align 4
741 741
742;;; do { 742;;; do {
743;;; match = s->window + cur_match; 743;;; match = s->window + cur_match;
744;;; if (*(ushf*)(match+best_len-1) != scan_end || 744;;; if (*(ushf*)(match+best_len-1) != scan_end ||
745;;; *(ushf*)match != scan_start) continue; 745;;; *(ushf*)match != scan_start) continue;
746;;; [...] 746;;; [...]
747;;; } while ((cur_match = prev[cur_match & wmask]) > limit 747;;; } while ((cur_match = prev[cur_match & wmask]) > limit
748;;; && --chain_length != 0); 748;;; && --chain_length != 0);
749;;; 749;;;
750;;; Here is the inner loop of the function. The function will spend the 750;;; Here is the inner loop of the function. The function will spend the
751;;; majority of its time in this loop, and majority of that time will 751;;; majority of its time in this loop, and majority of that time will
752;;; be spent in the first ten instructions. 752;;; be spent in the first ten instructions.
753;;; 753;;;
754;;; Within this loop: 754;;; Within this loop:
755;;; ebx = scanend 755;;; ebx = scanend
756;;; ecx = curmatch 756;;; ecx = curmatch
757;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) 757;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask)
758;;; esi = windowbestlen - i.e., (window + bestlen) 758;;; esi = windowbestlen - i.e., (window + bestlen)
759;;; edi = prev 759;;; edi = prev
760;;; ebp = limit 760;;; ebp = limit
761 761
762LookupLoop: 762LookupLoop:
763 and ecx, edx 763 and ecx, edx
764 movzx ecx, word ptr [edi + ecx*2] 764 movzx ecx, word ptr [edi + ecx*2]
765 cmp ecx, ebp 765 cmp ecx, ebp
766 jbe LeaveNow 766 jbe LeaveNow
767 sub edx, 00010000h 767 sub edx, 00010000h
768 js LeaveNow 768 js LeaveNow
769LoopEntry: movzx eax, word ptr [esi + ecx - 1] 769LoopEntry: movzx eax, word ptr [esi + ecx - 1]
770 cmp eax, ebx 770 cmp eax, ebx
771 jnz LookupLoop 771 jnz LookupLoop
772 mov eax, [window] 772 mov eax, [window]
773 movzx eax, word ptr [eax + ecx] 773 movzx eax, word ptr [eax + ecx]
774 cmp eax, [scanstart] 774 cmp eax, [scanstart]
775 jnz LookupLoop 775 jnz LookupLoop
776 776
777;;; Store the current value of chainlen. 777;;; Store the current value of chainlen.
778 778
779 mov [chainlenwmask], edx 779 mov [chainlenwmask], edx
780 780
781;;; Point edi to the string under scrutiny, and esi to the string we 781;;; Point edi to the string under scrutiny, and esi to the string we
782;;; are hoping to match it up with. In actuality, esi and edi are 782;;; are hoping to match it up with. In actuality, esi and edi are
783;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is 783;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is
784;;; initialized to -(MAX_MATCH_8 - scanalign). 784;;; initialized to -(MAX_MATCH_8 - scanalign).
785 785
786 mov esi, [window] 786 mov esi, [window]
787 mov edi, [scan] 787 mov edi, [scan]
788 add esi, ecx 788 add esi, ecx
789 mov eax, [scanalign] 789 mov eax, [scanalign]
790 mov edx, 0fffffef8h; -(MAX_MATCH_8) 790 mov edx, 0fffffef8h; -(MAX_MATCH_8)
791 lea edi, [edi + eax + 0108h] ;MAX_MATCH_8] 791 lea edi, [edi + eax + 0108h] ;MAX_MATCH_8]
792 lea esi, [esi + eax + 0108h] ;MAX_MATCH_8] 792 lea esi, [esi + eax + 0108h] ;MAX_MATCH_8]
793 793
794;;; Test the strings for equality, 8 bytes at a time. At the end, 794;;; Test the strings for equality, 8 bytes at a time. At the end,
795;;; adjust edx so that it is offset to the exact byte that mismatched. 795;;; adjust edx so that it is offset to the exact byte that mismatched.
796;;; 796;;;
797;;; We already know at this point that the first three bytes of the 797;;; We already know at this point that the first three bytes of the
798;;; strings match each other, and they can be safely passed over before 798;;; strings match each other, and they can be safely passed over before
799;;; starting the compare loop. So what this code does is skip over 0-3 799;;; starting the compare loop. So what this code does is skip over 0-3
800;;; bytes, as much as necessary in order to dword-align the edi 800;;; bytes, as much as necessary in order to dword-align the edi
801;;; pointer. (esi will still be misaligned three times out of four.) 801;;; pointer. (esi will still be misaligned three times out of four.)
802;;; 802;;;
803;;; It should be confessed that this loop usually does not represent 803;;; It should be confessed that this loop usually does not represent
804;;; much of the total running time. Replacing it with a more 804;;; much of the total running time. Replacing it with a more
805;;; straightforward "rep cmpsb" would not drastically degrade 805;;; straightforward "rep cmpsb" would not drastically degrade
806;;; performance. 806;;; performance.
807 807
808LoopCmps: 808LoopCmps:
809 mov eax, [esi + edx] 809 mov eax, [esi + edx]
810 xor eax, [edi + edx] 810 xor eax, [edi + edx]
811 jnz LeaveLoopCmps 811 jnz LeaveLoopCmps
812 mov eax, [esi + edx + 4] 812 mov eax, [esi + edx + 4]
813 xor eax, [edi + edx + 4] 813 xor eax, [edi + edx + 4]
814 jnz LeaveLoopCmps4 814 jnz LeaveLoopCmps4
815 add edx, 8 815 add edx, 8
816 jnz LoopCmps 816 jnz LoopCmps
817 jmp short LenMaximum 817 jmp short LenMaximum
818LeaveLoopCmps4: add edx, 4 818LeaveLoopCmps4: add edx, 4
819LeaveLoopCmps: test eax, 0000FFFFh 819LeaveLoopCmps: test eax, 0000FFFFh
820 jnz LenLower 820 jnz LenLower
821 add edx, 2 821 add edx, 2
822 shr eax, 16 822 shr eax, 16
823LenLower: sub al, 1 823LenLower: sub al, 1
824 adc edx, 0 824 adc edx, 0
825 825
826;;; Calculate the length of the match. If it is longer than MAX_MATCH, 826;;; Calculate the length of the match. If it is longer than MAX_MATCH,
827;;; then automatically accept it as the best possible match and leave. 827;;; then automatically accept it as the best possible match and leave.
828 828
829 lea eax, [edi + edx] 829 lea eax, [edi + edx]
830 mov edi, [scan] 830 mov edi, [scan]
831 sub eax, edi 831 sub eax, edi
832 cmp eax, MAX_MATCH 832 cmp eax, MAX_MATCH
833 jge LenMaximum 833 jge LenMaximum
834 834
835;;; If the length of the match is not longer than the best match we 835;;; If the length of the match is not longer than the best match we
836;;; have so far, then forget it and return to the lookup loop. 836;;; have so far, then forget it and return to the lookup loop.
837 837
838 mov edx, [deflatestate] 838 mov edx, [deflatestate]
839 mov ebx, [bestlen] 839 mov ebx, [bestlen]
840 cmp eax, ebx 840 cmp eax, ebx
841 jg LongerMatch 841 jg LongerMatch
842 mov esi, [windowbestlen] 842 mov esi, [windowbestlen]
843 mov edi, [edx + dsPrev] 843 mov edi, [edx + dsPrev]
844 mov ebx, [scanend] 844 mov ebx, [scanend]
845 mov edx, [chainlenwmask] 845 mov edx, [chainlenwmask]
846 jmp LookupLoop 846 jmp LookupLoop
847 847
848;;; s->match_start = cur_match; 848;;; s->match_start = cur_match;
849;;; best_len = len; 849;;; best_len = len;
850;;; if (len >= nice_match) break; 850;;; if (len >= nice_match) break;
851;;; scan_end = *(ushf*)(scan+best_len-1); 851;;; scan_end = *(ushf*)(scan+best_len-1);
852 852
853LongerMatch: mov ebx, [nicematch] 853LongerMatch: mov ebx, [nicematch]
854 mov [bestlen], eax 854 mov [bestlen], eax
855 mov [edx + dsMatchStart], ecx 855 mov [edx + dsMatchStart], ecx
856 cmp eax, ebx 856 cmp eax, ebx
857 jge LeaveNow 857 jge LeaveNow
858 mov esi, [window] 858 mov esi, [window]
859 add esi, eax 859 add esi, eax
860 mov [windowbestlen], esi 860 mov [windowbestlen], esi
861 movzx ebx, word ptr [edi + eax - 1] 861 movzx ebx, word ptr [edi + eax - 1]
862 mov edi, [edx + dsPrev] 862 mov edi, [edx + dsPrev]
863 mov [scanend], ebx 863 mov [scanend], ebx
864 mov edx, [chainlenwmask] 864 mov edx, [chainlenwmask]
865 jmp LookupLoop 865 jmp LookupLoop
866 866
867;;; Accept the current string, with the maximum possible length. 867;;; Accept the current string, with the maximum possible length.
868 868
869LenMaximum: mov edx, [deflatestate] 869LenMaximum: mov edx, [deflatestate]
870 mov dword ptr [bestlen], MAX_MATCH 870 mov dword ptr [bestlen], MAX_MATCH
871 mov [edx + dsMatchStart], ecx 871 mov [edx + dsMatchStart], ecx
872 872
873;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len; 873;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
874;;; return s->lookahead; 874;;; return s->lookahead;
875 875
876LeaveNow: 876LeaveNow:
877 mov edx, [deflatestate] 877 mov edx, [deflatestate]
878 mov ebx, [bestlen] 878 mov ebx, [bestlen]
879 mov eax, [edx + dsLookahead] 879 mov eax, [edx + dsLookahead]
880 cmp ebx, eax 880 cmp ebx, eax
881 jg LookaheadRet 881 jg LookaheadRet
882 mov eax, ebx 882 mov eax, ebx
883LookaheadRet: 883LookaheadRet:
884 884
885;;; Restore the stack and return from whence we came. 885;;; Restore the stack and return from whence we came.
886 886
887 add esp, LocalVarsSize 887 add esp, LocalVarsSize
888 pop ebx 888 pop ebx
889 pop esi 889 pop esi
890 pop edi 890 pop edi
891 pop ebp 891 pop ebp
892 892
893 ret 893 ret
894; please don't remove this string ! 894; please don't remove this string !
895; Your are free use gvmat32 in any fre or commercial apps if you don't remove the string in the binary! 895; Your can freely use gvmat32 in any free or commercial app if you don't remove the string in the binary!
896 db 0dh,0ah,"asm686 with masm, code optimised assembly code from Brian Raiter, written 1998",0dh,0ah 896 db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998",0dh,0ah
897 897
898IFDEF NOUNDERLINE 898IFDEF NOUNDERLINE
899longest_match_686 endp 899longest_match_686 endp
900ELSE 900ELSE
901_longest_match_686 endp 901_longest_match_686 endp
902ENDIF 902ENDIF
903 903
904_TEXT ends 904_TEXT ends
905end 905end
diff --git a/contrib/vstudio/vc70_32/gvmat32c.c b/contrib/masmx86/gvmat32c.c
index 38be10b..9ed25f3 100644
--- a/contrib/vstudio/vc70_32/gvmat32c.c
+++ b/contrib/masmx86/gvmat32c.c
@@ -1,209 +1,206 @@
1/* gvmat32.c -- C portion of the optimized longest_match for 32 bits x86 1/* gvmat32.c -- C portion of the optimized longest_match for 32 bits x86
2 * Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant. 2 * Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant.
3 * File written by Gilles Vollant, by modifiying the longest_match 3 * File written by Gilles Vollant, by modifiying the longest_match
4 * from Jean-loup Gailly in deflate.c 4 * from Jean-loup Gailly in deflate.c
5 * it prepare all parameters and call the assembly longest_match_gvasm 5 * it prepare all parameters and call the assembly longest_match_gvasm
6 * longest_match execute standard C code is wmask != 0x7fff 6 * longest_match execute standard C code is wmask != 0x7fff
7 * (assembly code is faster with a fixed wmask) 7 * (assembly code is faster with a fixed wmask)
8 * 8 *
9 */ 9 */
10 10
11#include "deflate.h" 11#include "deflate.h"
12 12
13#undef FAR 13#ifdef ASMV
14//#include <windows.h> 14#define NIL 0
15 15
16#ifdef ASMV 16#define UNALIGNED_OK
17#define NIL 0 17
18 18
19#define UNALIGNED_OK 19/* if your C compiler don't add underline before function name,
20 20 define ADD_UNDERLINE_ASMFUNC */
21 21#ifdef ADD_UNDERLINE_ASMFUNC
22/* if your C compiler don't add underline before function name, 22#define longest_match_7fff _longest_match_7fff
23 define ADD_UNDERLINE_ASMFUNC */ 23#define longest_match_686 _longest_match_686
24#ifdef ADD_UNDERLINE_ASMFUNC 24#define cpudetect32 _cpudetect32
25#define longest_match_7fff _longest_match_7fff 25#endif
26#define longest_match_686 _longest_match_686 26
27#define cpudetect32 _cpudetect32 27
28#endif 28
29 29void match_init()
30 30{
31 31}
32void match_init() 32
33{ 33unsigned long cpudetect32();
34} 34
35 35uInt longest_match_c(
36unsigned long cpudetect32(); 36 deflate_state *s,
37 37 IPos cur_match); /* current match */
38uInt longest_match_c( 38
39 deflate_state *s, 39
40 IPos cur_match); /* current match */ 40uInt longest_match_7fff(
41 41 deflate_state *s,
42 42 IPos cur_match); /* current match */
43uInt longest_match_7fff( 43
44 deflate_state *s, 44uInt longest_match_686(
45 IPos cur_match); /* current match */ 45 deflate_state *s,
46 46 IPos cur_match); /* current match */
47uInt longest_match_686( 47
48 deflate_state *s, 48uInt longest_match(
49 IPos cur_match); /* current match */ 49 deflate_state *s,
50 50 IPos cur_match) /* current match */
51uInt longest_match( 51{
52 deflate_state *s, 52 static uInt iIsPPro=2;
53 IPos cur_match) /* current match */ 53
54{ 54 if ((s->w_mask == 0x7fff) && (iIsPPro==0))
55 static uInt iIsPPro=2; 55 return longest_match_7fff(s,cur_match);
56 56
57 if ((s->w_mask == 0x7fff) && (iIsPPro==0)) 57 if (iIsPPro==1)
58 return longest_match_7fff(s,cur_match); 58 return longest_match_686(s,cur_match);
59 59
60 if (iIsPPro==1) 60 if (iIsPPro==2)
61 return longest_match_686(s,cur_match); 61 iIsPPro = (((cpudetect32()/0x100)&0xf)>=6) ? 1 : 0;
62 62
63 if (iIsPPro==2) 63 return longest_match_c(s,cur_match);
64 iIsPPro = (((cpudetect32()/0x100)&0xf)>=6) ? 1 : 0; 64}
65 65
66 return longest_match_c(s,cur_match); 66
67} 67
68 68uInt longest_match_c(s, cur_match)
69 69 deflate_state *s;
70 70 IPos cur_match; /* current match */
71uInt longest_match_c(s, cur_match) 71{
72 deflate_state *s; 72 unsigned chain_length = s->max_chain_length;/* max hash chain length */
73 IPos cur_match; /* current match */ 73 register Bytef *scan = s->window + s->strstart; /* current string */
74{ 74 register Bytef *match; /* matched string */
75 unsigned chain_length = s->max_chain_length;/* max hash chain length */ 75 register int len; /* length of current match */
76 register Bytef *scan = s->window + s->strstart; /* current string */ 76 int best_len = s->prev_length; /* best match length so far */
77 register Bytef *match; /* matched string */ 77 int nice_match = s->nice_match; /* stop if match long enough */
78 register int len; /* length of current match */ 78 IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
79 int best_len = s->prev_length; /* best match length so far */ 79 s->strstart - (IPos)MAX_DIST(s) : NIL;
80 int nice_match = s->nice_match; /* stop if match long enough */ 80 /* Stop when cur_match becomes <= limit. To simplify the code,
81 IPos limit = s->strstart > (IPos)MAX_DIST(s) ? 81 * we prevent matches with the string of window index 0.
82 s->strstart - (IPos)MAX_DIST(s) : NIL; 82 */
83 /* Stop when cur_match becomes <= limit. To simplify the code, 83 Posf *prev = s->prev;
84 * we prevent matches with the string of window index 0. 84 uInt wmask = s->w_mask;
85 */ 85
86 Posf *prev = s->prev; 86#ifdef UNALIGNED_OK
87 uInt wmask = s->w_mask; 87 /* Compare two bytes at a time. Note: this is not always beneficial.
88 88 * Try with and without -DUNALIGNED_OK to check.
89#ifdef UNALIGNED_OK 89 */
90 /* Compare two bytes at a time. Note: this is not always beneficial. 90 register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
91 * Try with and without -DUNALIGNED_OK to check. 91 register ush scan_start = *(ushf*)scan;
92 */ 92 register ush scan_end = *(ushf*)(scan+best_len-1);
93 register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; 93#else
94 register ush scan_start = *(ushf*)scan; 94 register Bytef *strend = s->window + s->strstart + MAX_MATCH;
95 register ush scan_end = *(ushf*)(scan+best_len-1); 95 register Byte scan_end1 = scan[best_len-1];
96#else 96 register Byte scan_end = scan[best_len];
97 register Bytef *strend = s->window + s->strstart + MAX_MATCH; 97#endif
98 register Byte scan_end1 = scan[best_len-1]; 98
99 register Byte scan_end = scan[best_len]; 99 /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
100#endif 100 * It is easy to get rid of this optimization if necessary.
101 101 */
102 /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. 102 Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
103 * It is easy to get rid of this optimization if necessary. 103
104 */ 104 /* Do not waste too much time if we already have a good match: */
105 Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); 105 if (s->prev_length >= s->good_match) {
106 106 chain_length >>= 2;
107 /* Do not waste too much time if we already have a good match: */ 107 }
108 if (s->prev_length >= s->good_match) { 108 /* Do not look for matches beyond the end of the input. This is necessary
109 chain_length >>= 2; 109 * to make deflate deterministic.
110 } 110 */
111 /* Do not look for matches beyond the end of the input. This is necessary 111 if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
112 * to make deflate deterministic. 112
113 */ 113 Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
114 if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; 114
115 115 do {
116 Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); 116 Assert(cur_match < s->strstart, "no future");
117 117 match = s->window + cur_match;
118 do { 118
119 Assert(cur_match < s->strstart, "no future"); 119 /* Skip to next match if the match length cannot increase
120 match = s->window + cur_match; 120 * or if the match length is less than 2:
121 121 */
122 /* Skip to next match if the match length cannot increase 122#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
123 * or if the match length is less than 2: 123 /* This code assumes sizeof(unsigned short) == 2. Do not use
124 */ 124 * UNALIGNED_OK if your compiler uses a different size.
125#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) 125 */
126 /* This code assumes sizeof(unsigned short) == 2. Do not use 126 if (*(ushf*)(match+best_len-1) != scan_end ||
127 * UNALIGNED_OK if your compiler uses a different size. 127 *(ushf*)match != scan_start) continue;
128 */ 128
129 if (*(ushf*)(match+best_len-1) != scan_end || 129 /* It is not necessary to compare scan[2] and match[2] since they are
130 *(ushf*)match != scan_start) continue; 130 * always equal when the other bytes match, given that the hash keys
131 131 * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
132 /* It is not necessary to compare scan[2] and match[2] since they are 132 * strstart+3, +5, ... up to strstart+257. We check for insufficient
133 * always equal when the other bytes match, given that the hash keys 133 * lookahead only every 4th comparison; the 128th check will be made
134 * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at 134 * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
135 * strstart+3, +5, ... up to strstart+257. We check for insufficient 135 * necessary to put more guard bytes at the end of the window, or
136 * lookahead only every 4th comparison; the 128th check will be made 136 * to check more often for insufficient lookahead.
137 * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is 137 */
138 * necessary to put more guard bytes at the end of the window, or 138 Assert(scan[2] == match[2], "scan[2]?");
139 * to check more often for insufficient lookahead. 139 scan++, match++;
140 */ 140 do {
141 Assert(scan[2] == match[2], "scan[2]?"); 141 } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
142 scan++, match++; 142 *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
143 do { 143 *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
144 } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && 144 *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
145 *(ushf*)(scan+=2) == *(ushf*)(match+=2) && 145 scan < strend);
146 *(ushf*)(scan+=2) == *(ushf*)(match+=2) && 146 /* The funny "do {}" generates better code on most compilers */
147 *(ushf*)(scan+=2) == *(ushf*)(match+=2) && 147
148 scan < strend); 148 /* Here, scan <= window+strstart+257 */
149 /* The funny "do {}" generates better code on most compilers */ 149 Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
150 150 if (*scan == *match) scan++;
151 /* Here, scan <= window+strstart+257 */ 151
152 Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); 152 len = (MAX_MATCH - 1) - (int)(strend-scan);
153 if (*scan == *match) scan++; 153 scan = strend - (MAX_MATCH-1);
154 154
155 len = (MAX_MATCH - 1) - (int)(strend-scan); 155#else /* UNALIGNED_OK */
156 scan = strend - (MAX_MATCH-1); 156
157 157 if (match[best_len] != scan_end ||
158#else /* UNALIGNED_OK */ 158 match[best_len-1] != scan_end1 ||
159 159 *match != *scan ||
160 if (match[best_len] != scan_end || 160 *++match != scan[1]) continue;
161 match[best_len-1] != scan_end1 || 161
162 *match != *scan || 162 /* The check at best_len-1 can be removed because it will be made
163 *++match != scan[1]) continue; 163 * again later. (This heuristic is not always a win.)
164 164 * It is not necessary to compare scan[2] and match[2] since they
165 /* The check at best_len-1 can be removed because it will be made 165 * are always equal when the other bytes match, given that
166 * again later. (This heuristic is not always a win.) 166 * the hash keys are equal and that HASH_BITS >= 8.
167 * It is not necessary to compare scan[2] and match[2] since they 167 */
168 * are always equal when the other bytes match, given that 168 scan += 2, match++;
169 * the hash keys are equal and that HASH_BITS >= 8. 169 Assert(*scan == *match, "match[2]?");
170 */ 170
171 scan += 2, match++; 171 /* We check for insufficient lookahead only every 8th comparison;
172 Assert(*scan == *match, "match[2]?"); 172 * the 256th check will be made at strstart+258.
173 173 */
174 /* We check for insufficient lookahead only every 8th comparison; 174 do {
175 * the 256th check will be made at strstart+258. 175 } while (*++scan == *++match && *++scan == *++match &&
176 */ 176 *++scan == *++match && *++scan == *++match &&
177 do { 177 *++scan == *++match && *++scan == *++match &&
178 } while (*++scan == *++match && *++scan == *++match && 178 *++scan == *++match && *++scan == *++match &&
179 *++scan == *++match && *++scan == *++match && 179 scan < strend);
180 *++scan == *++match && *++scan == *++match && 180
181 *++scan == *++match && *++scan == *++match && 181 Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
182 scan < strend); 182
183 183 len = MAX_MATCH - (int)(strend - scan);
184 Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); 184 scan = strend - MAX_MATCH;
185 185
186 len = MAX_MATCH - (int)(strend - scan); 186#endif /* UNALIGNED_OK */
187 scan = strend - MAX_MATCH; 187
188 188 if (len > best_len) {
189#endif /* UNALIGNED_OK */ 189 s->match_start = cur_match;
190 190 best_len = len;
191 if (len > best_len) { 191 if (len >= nice_match) break;
192 s->match_start = cur_match; 192#ifdef UNALIGNED_OK
193 best_len = len; 193 scan_end = *(ushf*)(scan+best_len-1);
194 if (len >= nice_match) break; 194#else
195#ifdef UNALIGNED_OK 195 scan_end1 = scan[best_len-1];
196 scan_end = *(ushf*)(scan+best_len-1); 196 scan_end = scan[best_len];
197#else 197#endif
198 scan_end1 = scan[best_len-1]; 198 }
199 scan_end = scan[best_len]; 199 } while ((cur_match = prev[cur_match & wmask]) > limit
200#endif 200 && --chain_length != 0);
201 } 201
202 } while ((cur_match = prev[cur_match & wmask]) > limit 202 if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
203 && --chain_length != 0); 203 return s->lookahead;
204 204}
205 if ((uInt)best_len <= s->lookahead) return (uInt)best_len; 205
206 return s->lookahead; 206#endif /* ASMV */
207}
208
209#endif /* ASMV */
diff --git a/contrib/vstudio/vc70_32/gvmat32.obj b/contrib/vstudio/vc7/gvmat32.obj
index 5b2f856..5b2f856 100644
--- a/contrib/vstudio/vc70_32/gvmat32.obj
+++ b/contrib/vstudio/vc7/gvmat32.obj
Binary files differ
diff --git a/contrib/vstudio/vc7/inffas32.obj b/contrib/vstudio/vc7/inffas32.obj
new file mode 100644
index 0000000..a541a5a
--- /dev/null
+++ b/contrib/vstudio/vc7/inffas32.obj
Binary files differ
diff --git a/contrib/vstudio/vc70_32/miniunz.vcproj b/contrib/vstudio/vc7/miniunz.vcproj
index 1c6967f..935c250 100644
--- a/contrib/vstudio/vc70_32/miniunz.vcproj
+++ b/contrib/vstudio/vc7/miniunz.vcproj
@@ -19,7 +19,7 @@
19 <Tool 19 <Tool
20 Name="VCCLCompilerTool" 20 Name="VCCLCompilerTool"
21 Optimization="0" 21 Optimization="0"
22 PreprocessorDefinitions="WIN32;ZLIB_DLL;_DEBUG;_CONSOLE" 22 PreprocessorDefinitions="WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE"
23 MinimalRebuild="TRUE" 23 MinimalRebuild="TRUE"
24 BasicRuntimeChecks="3" 24 BasicRuntimeChecks="3"
25 RuntimeLibrary="5" 25 RuntimeLibrary="5"
@@ -63,7 +63,7 @@
63 Optimization="2" 63 Optimization="2"
64 InlineFunctionExpansion="1" 64 InlineFunctionExpansion="1"
65 OmitFramePointers="TRUE" 65 OmitFramePointers="TRUE"
66 PreprocessorDefinitions="WIN32;ZLIB_DLL;NDEBUG;_CONSOLE" 66 PreprocessorDefinitions="WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE"
67 StringPooling="TRUE" 67 StringPooling="TRUE"
68 RuntimeLibrary="4" 68 RuntimeLibrary="4"
69 EnableFunctionLevelLinking="TRUE" 69 EnableFunctionLevelLinking="TRUE"
@@ -116,7 +116,7 @@
116 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"> 116 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
117 </Filter> 117 </Filter>
118 <File 118 <File
119 RelativePath="zlib.lib"> 119 RelativePath="zlibwapi.lib">
120 </File> 120 </File>
121 </Files> 121 </Files>
122 <Globals> 122 <Globals>
diff --git a/contrib/vstudio/vc70_32/minizip.vcproj b/contrib/vstudio/vc7/minizip.vcproj
index 93e2a41..e6f9107 100644
--- a/contrib/vstudio/vc70_32/minizip.vcproj
+++ b/contrib/vstudio/vc7/minizip.vcproj
@@ -19,7 +19,7 @@
19 <Tool 19 <Tool
20 Name="VCCLCompilerTool" 20 Name="VCCLCompilerTool"
21 Optimization="0" 21 Optimization="0"
22 PreprocessorDefinitions="WIN32;ZLIB_DLL;_DEBUG;_CONSOLE" 22 PreprocessorDefinitions="WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE"
23 MinimalRebuild="TRUE" 23 MinimalRebuild="TRUE"
24 BasicRuntimeChecks="3" 24 BasicRuntimeChecks="3"
25 RuntimeLibrary="5" 25 RuntimeLibrary="5"
@@ -63,7 +63,7 @@
63 Optimization="2" 63 Optimization="2"
64 InlineFunctionExpansion="1" 64 InlineFunctionExpansion="1"
65 OmitFramePointers="TRUE" 65 OmitFramePointers="TRUE"
66 PreprocessorDefinitions="WIN32;ZLIB_DLL;NDEBUG;_CONSOLE" 66 PreprocessorDefinitions="WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE"
67 StringPooling="TRUE" 67 StringPooling="TRUE"
68 RuntimeLibrary="4" 68 RuntimeLibrary="4"
69 EnableFunctionLevelLinking="TRUE" 69 EnableFunctionLevelLinking="TRUE"
@@ -116,7 +116,7 @@
116 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"> 116 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
117 </Filter> 117 </Filter>
118 <File 118 <File
119 RelativePath="zlib.lib"> 119 RelativePath="zlibwapi.lib">
120 </File> 120 </File>
121 </Files> 121 </Files>
122 <Globals> 122 <Globals>
diff --git a/contrib/vstudio/vc70_32/zlib.rc b/contrib/vstudio/vc7/zlib.rc
index 6c51679..6c51679 100644
--- a/contrib/vstudio/vc70_32/zlib.rc
+++ b/contrib/vstudio/vc7/zlib.rc
diff --git a/contrib/vstudio/vc70_32/zlibstat.vcproj b/contrib/vstudio/vc7/zlibstat.vcproj
index 7470b58..eb182f7 100644
--- a/contrib/vstudio/vc70_32/zlibstat.vcproj
+++ b/contrib/vstudio/vc7/zlibstat.vcproj
@@ -20,7 +20,7 @@
20 <Tool 20 <Tool
21 Name="VCCLCompilerTool" 21 Name="VCCLCompilerTool"
22 Optimization="0" 22 Optimization="0"
23 PreprocessorDefinitions="WIN32;ZLIB_DLL" 23 PreprocessorDefinitions="WIN32;ZLIB_WINAPI"
24 ExceptionHandling="FALSE" 24 ExceptionHandling="FALSE"
25 RuntimeLibrary="5" 25 RuntimeLibrary="5"
26 PrecompiledHeaderFile=".\zlibstatDebug/zlibstat.pch" 26 PrecompiledHeaderFile=".\zlibstatDebug/zlibstat.pch"
@@ -61,7 +61,7 @@
61 <Tool 61 <Tool
62 Name="VCCLCompilerTool" 62 Name="VCCLCompilerTool"
63 InlineFunctionExpansion="1" 63 InlineFunctionExpansion="1"
64 PreprocessorDefinitions="WIN32;ZLIB_DLL" 64 PreprocessorDefinitions="WIN32;ZLIB_WINAPI"
65 StringPooling="TRUE" 65 StringPooling="TRUE"
66 ExceptionHandling="FALSE" 66 ExceptionHandling="FALSE"
67 RuntimeLibrary="4" 67 RuntimeLibrary="4"
@@ -102,7 +102,7 @@
102 <Tool 102 <Tool
103 Name="VCCLCompilerTool" 103 Name="VCCLCompilerTool"
104 InlineFunctionExpansion="1" 104 InlineFunctionExpansion="1"
105 PreprocessorDefinitions="WIN32;ZLIB_DLL,ASMV" 105 PreprocessorDefinitions="WIN32;ZLIB_WINAPI;ASMV;ASMINF"
106 StringPooling="TRUE" 106 StringPooling="TRUE"
107 ExceptionHandling="FALSE" 107 ExceptionHandling="FALSE"
108 RuntimeLibrary="4" 108 RuntimeLibrary="4"
@@ -117,7 +117,7 @@
117 Name="VCCustomBuildTool"/> 117 Name="VCCustomBuildTool"/>
118 <Tool 118 <Tool
119 Name="VCLibrarianTool" 119 Name="VCLibrarianTool"
120 AdditionalOptions="gvmat32.obj inffastAsm.obj /NODEFAULTLIB " 120 AdditionalOptions="gvmat32.obj inffas32.obj /NODEFAULTLIB "
121 OutputFile=".\zlibstat\zlibstat.lib" 121 OutputFile=".\zlibstat\zlibstat.lib"
122 SuppressStartupBanner="TRUE"/> 122 SuppressStartupBanner="TRUE"/>
123 <Tool 123 <Tool
@@ -144,7 +144,7 @@
144 <Tool 144 <Tool
145 Name="VCCLCompilerTool" 145 Name="VCCLCompilerTool"
146 InlineFunctionExpansion="1" 146 InlineFunctionExpansion="1"
147 PreprocessorDefinitions="WIN32;ZLIB_DLL" 147 PreprocessorDefinitions="WIN32;ZLIB_WINAPI"
148 StringPooling="TRUE" 148 StringPooling="TRUE"
149 ExceptionHandling="FALSE" 149 ExceptionHandling="FALSE"
150 RuntimeLibrary="4" 150 RuntimeLibrary="4"
@@ -204,17 +204,6 @@
204 </File> 204 </File>
205 <File 205 <File
206 RelativePath=".\inffast.c"> 206 RelativePath=".\inffast.c">
207 <FileConfiguration
208 Name="Release|Win32"
209 ExcludedFromBuild="TRUE">
210 <Tool
211 Name="VCCLCompilerTool"/>
212 </FileConfiguration>
213 <FileConfiguration
214 Name="ReleaseWithoutAsm|Win32">
215 <Tool
216 Name="VCCLCompilerTool"/>
217 </FileConfiguration>
218 </File> 207 </File>
219 <File 208 <File
220 RelativePath=".\inflate.c"> 209 RelativePath=".\inflate.c">
diff --git a/contrib/vstudio/vc70_32/zlibvc.def b/contrib/vstudio/vc7/zlibvc.def
index c2804a8..63b3e6d 100644
--- a/contrib/vstudio/vc70_32/zlibvc.def
+++ b/contrib/vstudio/vc7/zlibvc.def
@@ -1,4 +1,3 @@
1LIBRARY "zlib"
2 1
3VERSION 1.21 2VERSION 1.21
4 3
@@ -51,6 +50,10 @@ EXPORTS
51 inflateBack @44 50 inflateBack @44
52 inflateBackEnd @45 51 inflateBackEnd @45
53 compressBound @46 52 compressBound @46
53 deflateBound @47
54 gzclearerr @48
55 gzungetc @49
56 zlibCompileFlags @50
54 57
55 unzOpen @61 58 unzOpen @61
56 unzClose @62 59 unzClose @62
diff --git a/contrib/vstudio/vc70_32/zlibvc.sln b/contrib/vstudio/vc7/zlibvc.sln
index 5a007ff..5a007ff 100644
--- a/contrib/vstudio/vc70_32/zlibvc.sln
+++ b/contrib/vstudio/vc7/zlibvc.sln
diff --git a/contrib/vstudio/vc70_32/zlibvc.vcproj b/contrib/vstudio/vc7/zlibvc.vcproj
index 7a9e83a..4e57bcd 100644
--- a/contrib/vstudio/vc70_32/zlibvc.vcproj
+++ b/contrib/vstudio/vc7/zlibvc.vcproj
@@ -20,7 +20,7 @@
20 <Tool 20 <Tool
21 Name="VCCLCompilerTool" 21 Name="VCCLCompilerTool"
22 Optimization="0" 22 Optimization="0"
23 PreprocessorDefinitions="WIN32,ZLIB_DLL,ASMV" 23 PreprocessorDefinitions="WIN32,ZLIB_WINAPI,ASMV,ASMINF"
24 ExceptionHandling="FALSE" 24 ExceptionHandling="FALSE"
25 RuntimeLibrary="1" 25 RuntimeLibrary="1"
26 PrecompiledHeaderFile=".\DebugDll/zlibvc.pch" 26 PrecompiledHeaderFile=".\DebugDll/zlibvc.pch"
@@ -35,15 +35,15 @@
35 <Tool 35 <Tool
36 Name="VCLinkerTool" 36 Name="VCLinkerTool"
37 AdditionalOptions="/MACHINE:I386" 37 AdditionalOptions="/MACHINE:I386"
38 AdditionalDependencies="gvmat32.obj " 38 AdditionalDependencies="gvmat32.obj inffas32.obj"
39 OutputFile=".\DebugDll\zlib.dll" 39 OutputFile=".\DebugDll\zlibwapi.dll"
40 LinkIncremental="2" 40 LinkIncremental="2"
41 SuppressStartupBanner="TRUE" 41 SuppressStartupBanner="TRUE"
42 ModuleDefinitionFile=".\zlibvc.def" 42 ModuleDefinitionFile=".\zlibvc.def"
43 GenerateDebugInformation="TRUE" 43 GenerateDebugInformation="TRUE"
44 ProgramDatabaseFile=".\DebugDll/zlib.pdb" 44 ProgramDatabaseFile=".\DebugDll/zlibwapi.pdb"
45 SubSystem="2" 45 SubSystem="2"
46 ImportLibrary=".\DebugDll/zlib.lib"/> 46 ImportLibrary=".\DebugDll/zlibwapi.lib"/>
47 <Tool 47 <Tool
48 Name="VCMIDLTool" 48 Name="VCMIDLTool"
49 PreprocessorDefinitions="_DEBUG" 49 PreprocessorDefinitions="_DEBUG"
@@ -76,7 +76,7 @@
76 <Tool 76 <Tool
77 Name="VCCLCompilerTool" 77 Name="VCCLCompilerTool"
78 InlineFunctionExpansion="1" 78 InlineFunctionExpansion="1"
79 PreprocessorDefinitions="WIN32,ZLIB_DLL" 79 PreprocessorDefinitions="WIN32,ZLIB_WINAPI"
80 StringPooling="TRUE" 80 StringPooling="TRUE"
81 ExceptionHandling="FALSE" 81 ExceptionHandling="FALSE"
82 RuntimeLibrary="0" 82 RuntimeLibrary="0"
@@ -95,17 +95,17 @@
95 Name="VCLinkerTool" 95 Name="VCLinkerTool"
96 AdditionalOptions="/MACHINE:I386" 96 AdditionalOptions="/MACHINE:I386"
97 AdditionalDependencies="crtdll.lib" 97 AdditionalDependencies="crtdll.lib"
98 OutputFile=".\zlibDllWithoutAsm\zlib.dll" 98 OutputFile=".\zlibDllWithoutAsm\zlibwapi.dll"
99 LinkIncremental="1" 99 LinkIncremental="1"
100 SuppressStartupBanner="TRUE" 100 SuppressStartupBanner="TRUE"
101 IgnoreAllDefaultLibraries="TRUE" 101 IgnoreAllDefaultLibraries="TRUE"
102 ModuleDefinitionFile=".\zlibvc.def" 102 ModuleDefinitionFile=".\zlibvc.def"
103 ProgramDatabaseFile=".\zlibDllWithoutAsm/zlib.pdb" 103 ProgramDatabaseFile=".\zlibDllWithoutAsm/zlibwapi.pdb"
104 GenerateMapFile="TRUE" 104 GenerateMapFile="TRUE"
105 MapFileName=".\zlibDllWithoutAsm/zlib.map" 105 MapFileName=".\zlibDllWithoutAsm/zlibwapi.map"
106 SubSystem="2" 106 SubSystem="2"
107 OptimizeForWindows98="1" 107 OptimizeForWindows98="1"
108 ImportLibrary=".\zlibDllWithoutAsm/zlib.lib"/> 108 ImportLibrary=".\zlibDllWithoutAsm/zlibwapi.lib"/>
109 <Tool 109 <Tool
110 Name="VCMIDLTool" 110 Name="VCMIDLTool"
111 PreprocessorDefinitions="NDEBUG" 111 PreprocessorDefinitions="NDEBUG"
@@ -138,7 +138,7 @@
138 <Tool 138 <Tool
139 Name="VCCLCompilerTool" 139 Name="VCCLCompilerTool"
140 InlineFunctionExpansion="1" 140 InlineFunctionExpansion="1"
141 PreprocessorDefinitions="WIN32,ZLIB_DLL,ASMV" 141 PreprocessorDefinitions="WIN32,ZLIB_WINAPI,ASMV,ASMINF"
142 StringPooling="TRUE" 142 StringPooling="TRUE"
143 ExceptionHandling="FALSE" 143 ExceptionHandling="FALSE"
144 RuntimeLibrary="0" 144 RuntimeLibrary="0"
@@ -156,18 +156,18 @@
156 <Tool 156 <Tool
157 Name="VCLinkerTool" 157 Name="VCLinkerTool"
158 AdditionalOptions="/MACHINE:I386" 158 AdditionalOptions="/MACHINE:I386"
159 AdditionalDependencies="gvmat32.obj inffastAsm.obj " 159 AdditionalDependencies="gvmat32.obj inffas32.obj "
160 OutputFile=".\zlibDllWithoutCrtDll\zlib.dll" 160 OutputFile=".\zlibDllWithoutCrtDll\zlibwapi.dll"
161 LinkIncremental="1" 161 LinkIncremental="1"
162 SuppressStartupBanner="TRUE" 162 SuppressStartupBanner="TRUE"
163 IgnoreAllDefaultLibraries="FALSE" 163 IgnoreAllDefaultLibraries="FALSE"
164 ModuleDefinitionFile=".\zlibvc.def" 164 ModuleDefinitionFile=".\zlibvc.def"
165 ProgramDatabaseFile=".\zlibDllWithoutCrtDll/zlib.pdb" 165 ProgramDatabaseFile=".\zlibDllWithoutCrtDll/zlibwapi.pdb"
166 GenerateMapFile="TRUE" 166 GenerateMapFile="TRUE"
167 MapFileName=".\zlibDllWithoutCrtDll/zlib.map" 167 MapFileName=".\zlibDllWithoutCrtDll/zlibwapi.map"
168 SubSystem="2" 168 SubSystem="2"
169 OptimizeForWindows98="1" 169 OptimizeForWindows98="1"
170 ImportLibrary=".\zlibDllWithoutCrtDll/zlib.lib"/> 170 ImportLibrary=".\zlibDllWithoutCrtDll/zlibwapi.lib"/>
171 <Tool 171 <Tool
172 Name="VCMIDLTool" 172 Name="VCMIDLTool"
173 PreprocessorDefinitions="NDEBUG" 173 PreprocessorDefinitions="NDEBUG"
@@ -200,7 +200,7 @@
200 <Tool 200 <Tool
201 Name="VCCLCompilerTool" 201 Name="VCCLCompilerTool"
202 InlineFunctionExpansion="1" 202 InlineFunctionExpansion="1"
203 PreprocessorDefinitions="WIN32,ZLIB_DLL" 203 PreprocessorDefinitions="WIN32,ZLIB_WINAPI"
204 StringPooling="TRUE" 204 StringPooling="TRUE"
205 ExceptionHandling="FALSE" 205 ExceptionHandling="FALSE"
206 RuntimeLibrary="0" 206 RuntimeLibrary="0"
@@ -218,16 +218,16 @@
218 <Tool 218 <Tool
219 Name="VCLinkerTool" 219 Name="VCLinkerTool"
220 AdditionalDependencies="crtdll.lib" 220 AdditionalDependencies="crtdll.lib"
221 OutputFile="zlibvc__\zlib.dll" 221 OutputFile="zlibvc__\zlibwapi.dll"
222 LinkIncremental="1" 222 LinkIncremental="1"
223 SuppressStartupBanner="TRUE" 223 SuppressStartupBanner="TRUE"
224 IgnoreAllDefaultLibraries="TRUE" 224 IgnoreAllDefaultLibraries="TRUE"
225 ModuleDefinitionFile=".\zlibvc.def" 225 ModuleDefinitionFile=".\zlibvc.def"
226 ProgramDatabaseFile=".\zlibvc__/zlib.pdb" 226 ProgramDatabaseFile=".\zlibvc__/zlibwapi.pdb"
227 GenerateMapFile="TRUE" 227 GenerateMapFile="TRUE"
228 MapFileName=".\zlibvc__/zlib.map" 228 MapFileName=".\zlibvc__/zlibwapi.map"
229 SubSystem="2" 229 SubSystem="2"
230 ImportLibrary=".\zlibvc__/zlib.lib"/> 230 ImportLibrary=".\zlibvc__/zlibwapi.lib"/>
231 <Tool 231 <Tool
232 Name="VCMIDLTool" 232 Name="VCMIDLTool"
233 PreprocessorDefinitions="NDEBUG" 233 PreprocessorDefinitions="NDEBUG"
@@ -260,7 +260,7 @@
260 <Tool 260 <Tool
261 Name="VCCLCompilerTool" 261 Name="VCCLCompilerTool"
262 InlineFunctionExpansion="1" 262 InlineFunctionExpansion="1"
263 PreprocessorDefinitions="WIN32,ZLIB_DLL,ASMV" 263 PreprocessorDefinitions="WIN32,ZLIB_WINAPI,ASMV,ASMINF"
264 StringPooling="TRUE" 264 StringPooling="TRUE"
265 ExceptionHandling="FALSE" 265 ExceptionHandling="FALSE"
266 RuntimeLibrary="0" 266 RuntimeLibrary="0"
@@ -278,18 +278,18 @@
278 <Tool 278 <Tool
279 Name="VCLinkerTool" 279 Name="VCLinkerTool"
280 AdditionalOptions="/MACHINE:I386" 280 AdditionalOptions="/MACHINE:I386"
281 AdditionalDependencies="gvmat32.obj inffastAsm.obj crtdll.lib" 281 AdditionalDependencies="gvmat32.obj inffas32.obj crtdll.lib"
282 OutputFile=".\ReleaseDll\zlib.dll" 282 OutputFile=".\ReleaseDll\zlibwapi.dll"
283 LinkIncremental="1" 283 LinkIncremental="1"
284 SuppressStartupBanner="TRUE" 284 SuppressStartupBanner="TRUE"
285 IgnoreAllDefaultLibraries="TRUE" 285 IgnoreAllDefaultLibraries="TRUE"
286 ModuleDefinitionFile=".\zlibvc.def" 286 ModuleDefinitionFile=".\zlibvc.def"
287 ProgramDatabaseFile=".\ReleaseDll/zlib.pdb" 287 ProgramDatabaseFile=".\ReleaseDll/zlibwapi.pdb"
288 GenerateMapFile="TRUE" 288 GenerateMapFile="TRUE"
289 MapFileName=".\ReleaseDll/zlib.map" 289 MapFileName=".\ReleaseDll/zlibwapi.map"
290 SubSystem="2" 290 SubSystem="2"
291 OptimizeForWindows98="1" 291 OptimizeForWindows98="1"
292 ImportLibrary=".\ReleaseDll/zlib.lib"/> 292 ImportLibrary=".\ReleaseDll/zlibwapi.lib"/>
293 <Tool 293 <Tool
294 Name="VCMIDLTool" 294 Name="VCMIDLTool"
295 PreprocessorDefinitions="NDEBUG" 295 PreprocessorDefinitions="NDEBUG"
@@ -346,18 +346,6 @@
346 </File> 346 </File>
347 <File 347 <File
348 RelativePath=".\inffast.c"> 348 RelativePath=".\inffast.c">
349 <FileConfiguration
350 Name="ReleaseWithoutCrtdll|Win32"
351 ExcludedFromBuild="TRUE">
352 <Tool
353 Name="VCCLCompilerTool"/>
354 </FileConfiguration>
355 <FileConfiguration
356 Name="Release|Win32"
357 ExcludedFromBuild="TRUE">
358 <Tool
359 Name="VCCLCompilerTool"/>
360 </FileConfiguration>
361 </File> 349 </File>
362 <File 350 <File
363 RelativePath=".\inflate.c"> 351 RelativePath=".\inflate.c">
diff --git a/contrib/vstudio/vc70_32/inffastAsm.asm b/contrib/vstudio/vc70_32/inffastAsm.asm
deleted file mode 100644
index f4b6a56..0000000
--- a/contrib/vstudio/vc70_32/inffastAsm.asm
+++ /dev/null
@@ -1,1020 +0,0 @@
1; 75 "inffast.S"
2;FILE "inffast.S"
3
4;;;GLOBAL _inflate_fast
5
6;;;SECTION .text
7
8
9
10 .586p
11 .mmx
12
13 name inflate_fast_x86
14 .MODEL FLAT
15
16_DATA segment
17inflate_fast_use_mmx:
18dd 1
19
20
21_TEXT segment
22PUBLIC _inflate_fast
23
24ALIGN 4
25_inflate_fast:
26 jmp inflate_fast_entry
27
28
29
30ALIGN 4
31 db 'Fast decoding Code from Chris Anderson'
32 db 0
33
34ALIGN 4
35invalid_literal_length_code_msg:
36 db 'invalid literal/length code'
37 db 0
38
39ALIGN 4
40invalid_distance_code_msg:
41 db 'invalid distance code'
42 db 0
43
44ALIGN 4
45invalid_distance_too_far_msg:
46 db 'invalid distance too far back'
47 db 0
48
49
50ALIGN 4
51inflate_fast_mask:
52dd 0
53dd 1
54dd 3
55dd 7
56dd 15
57dd 31
58dd 63
59dd 127
60dd 255
61dd 511
62dd 1023
63dd 2047
64dd 4095
65dd 8191
66dd 16383
67dd 32767
68dd 65535
69dd 131071
70dd 262143
71dd 524287
72dd 1048575
73dd 2097151
74dd 4194303
75dd 8388607
76dd 16777215
77dd 33554431
78dd 67108863
79dd 134217727
80dd 268435455
81dd 536870911
82dd 1073741823
83dd 2147483647
84dd 4294967295
85
86
87;;SECTION .text
88; 205 "inffast.S"
89;GLOBAL inflate_fast_use_mmx
90
91;SECTION .data
92
93
94; GLOBAL inflate_fast_use_mmx:object
95;.size inflate_fast_use_mmx, 4
96; 226 "inffast.S"
97;SECTION .text
98
99ALIGN 4
100inflate_fast_entry:
101 push edi
102 push esi
103 push ebp
104 push ebx
105 pushfd
106 sub esp,64
107 cld
108
109
110
111
112 mov esi, [esp+88]
113 mov edi, [esi+28]
114
115
116
117
118
119
120
121 mov edx, [esi+4]
122 mov eax, [esi+0]
123
124 add edx,eax
125 sub edx,11
126
127 mov [esp+44],eax
128 mov [esp+20],edx
129
130 mov ebp, [esp+92]
131 mov ecx, [esi+16]
132 mov ebx, [esi+12]
133
134 sub ebp,ecx
135 neg ebp
136 add ebp,ebx
137
138 sub ecx,257
139 add ecx,ebx
140
141 mov [esp+60],ebx
142 mov [esp+40],ebp
143 mov [esp+16],ecx
144; 285 "inffast.S"
145 mov eax, [edi+64]
146 mov ecx, [edi+68]
147
148 mov [esp+8],eax
149 mov [esp+12],ecx
150
151 mov eax,1
152 mov ecx, [edi+72]
153 shl eax,cl
154 dec eax
155 mov [esp+0],eax
156
157 mov eax,1
158 mov ecx, [edi+76]
159 shl eax,cl
160 dec eax
161 mov [esp+4],eax
162
163 mov eax, [edi+32]
164 mov ecx, [edi+36]
165 mov edx, [edi+40]
166
167 mov [esp+52],eax
168 mov [esp+48],ecx
169 mov [esp+56],edx
170
171 mov ebp, [edi+44]
172 mov ebx, [edi+48]
173; 321 "inffast.S"
174 mov esi, [esp+44]
175 mov ecx, [esp+20]
176 cmp ecx,esi
177 ja L_align_long
178
179 add ecx,11
180 sub ecx,esi
181 mov eax,12
182 sub eax,ecx
183 lea edi, [esp+28]
184 rep movsb
185 mov ecx,eax
186 xor eax,eax
187 rep stosb
188 lea esi, [esp+28]
189 mov [esp+20],esi
190 jmp L_is_aligned
191
192
193L_align_long:
194 test esi,3
195 jz L_is_aligned
196 xor eax,eax
197 mov al, [esi]
198 inc esi
199 mov ecx,ebx
200 add ebx,8
201 shl eax,cl
202 or ebp,eax
203 jmp L_align_long
204
205L_is_aligned:
206 mov edi, [esp+60]
207; 366 "inffast.S"
208L_check_mmx:
209 cmp dword ptr [inflate_fast_use_mmx],2
210 je L_init_mmx
211 ja L_do_loop
212
213 push eax
214 push ebx
215 push ecx
216 push edx
217 pushfd
218 mov eax, [esp]
219 xor dword ptr [esp],0200000h
220
221
222
223
224 popfd
225 pushfd
226 pop edx
227 xor edx,eax
228 jz L_dont_use_mmx
229 xor eax,eax
230 cpuid
231 cmp ebx,0756e6547h
232 jne L_dont_use_mmx
233 cmp ecx,06c65746eh
234 jne L_dont_use_mmx
235 cmp edx,049656e69h
236 jne L_dont_use_mmx
237 mov eax,1
238 cpuid
239 shr eax,8
240 and eax,15
241 cmp eax,6
242 jne L_dont_use_mmx
243 test edx,0800000h
244 jnz L_use_mmx
245 jmp L_dont_use_mmx
246L_use_mmx:
247 mov dword ptr [inflate_fast_use_mmx],2
248 jmp L_check_mmx_pop
249L_dont_use_mmx:
250 mov dword ptr [inflate_fast_use_mmx],3
251L_check_mmx_pop:
252 pop edx
253 pop ecx
254 pop ebx
255 pop eax
256 jmp L_check_mmx
257; 426 "inffast.S"
258ALIGN 4
259L_do_loop:
260; 437 "inffast.S"
261 cmp bl,15
262 ja L_get_length_code
263
264 xor eax,eax
265 lodsw
266 mov cl,bl
267 add bl,16
268 shl eax,cl
269 or ebp,eax
270
271L_get_length_code:
272 mov edx, [esp+0]
273 mov ecx, [esp+8]
274 and edx,ebp
275 mov eax, [ecx+edx*4]
276
277L_dolen:
278
279
280
281
282
283
284 mov cl,ah
285 sub bl,ah
286 shr ebp,cl
287
288
289
290
291
292
293 test al,al
294 jnz L_test_for_length_base
295
296 shr eax,16
297 stosb
298
299L_while_test:
300
301
302 cmp [esp+16],edi
303 jbe L_break_loop
304
305 cmp [esp+20],esi
306 ja L_do_loop
307 jmp L_break_loop
308
309L_test_for_length_base:
310; 502 "inffast.S"
311 mov edx,eax
312 shr edx,16
313 mov cl,al
314
315 test al,16
316 jz L_test_for_second_level_length
317 and cl,15
318 jz L_save_len
319 cmp bl,cl
320 jae L_add_bits_to_len
321
322 mov ch,cl
323 xor eax,eax
324 lodsw
325 mov cl,bl
326 add bl,16
327 shl eax,cl
328 or ebp,eax
329 mov cl,ch
330
331L_add_bits_to_len:
332 mov eax,1
333 shl eax,cl
334 dec eax
335 sub bl,cl
336 and eax,ebp
337 shr ebp,cl
338 add edx,eax
339
340L_save_len:
341 mov [esp+24],edx
342
343
344L_decode_distance:
345; 549 "inffast.S"
346 cmp bl,15
347 ja L_get_distance_code
348
349 xor eax,eax
350 lodsw
351 mov cl,bl
352 add bl,16
353 shl eax,cl
354 or ebp,eax
355
356L_get_distance_code:
357 mov edx, [esp+4]
358 mov ecx, [esp+12]
359 and edx,ebp
360 mov eax, [ecx+edx*4]
361
362
363L_dodist:
364 mov edx,eax
365 shr edx,16
366 mov cl,ah
367 sub bl,ah
368 shr ebp,cl
369; 584 "inffast.S"
370 mov cl,al
371
372 test al,16
373 jz L_test_for_second_level_dist
374 and cl,15
375 jz L_check_dist_one
376 cmp bl,cl
377 jae L_add_bits_to_dist
378
379 mov ch,cl
380 xor eax,eax
381 lodsw
382 mov cl,bl
383 add bl,16
384 shl eax,cl
385 or ebp,eax
386 mov cl,ch
387
388L_add_bits_to_dist:
389 mov eax,1
390 shl eax,cl
391 dec eax
392 sub bl,cl
393 and eax,ebp
394 shr ebp,cl
395 add edx,eax
396 jmp L_check_window
397
398L_check_window:
399; 625 "inffast.S"
400 mov [esp+44],esi
401 mov eax,edi
402 sub eax, [esp+40]
403
404 cmp eax,edx
405 jb L_clip_window
406
407 mov ecx, [esp+24]
408 mov esi,edi
409 sub esi,edx
410
411 sub ecx,3
412 mov al, [esi]
413 mov [edi],al
414 mov al, [esi+1]
415 mov dl, [esi+2]
416 add esi,3
417 mov [edi+1],al
418 mov [edi+2],dl
419 add edi,3
420 rep movsb
421
422 mov esi, [esp+44]
423 jmp L_while_test
424
425ALIGN 4
426L_check_dist_one:
427 cmp edx,1
428 jne L_check_window
429 cmp [esp+40],edi
430 je L_check_window
431
432 dec edi
433 mov ecx, [esp+24]
434 mov al, [edi]
435 sub ecx,3
436
437 mov [edi+1],al
438 mov [edi+2],al
439 mov [edi+3],al
440 add edi,4
441 rep stosb
442
443 jmp L_while_test
444
445ALIGN 4
446L_test_for_second_level_length:
447
448
449
450
451 test al,64
452 jnz L_test_for_end_of_block
453
454 mov eax,1
455 shl eax,cl
456 dec eax
457 and eax,ebp
458 add eax,edx
459 mov edx, [esp+8]
460 mov eax, [edx+eax*4]
461 jmp L_dolen
462
463ALIGN 4
464L_test_for_second_level_dist:
465
466
467
468
469 test al,64
470 jnz L_invalid_distance_code
471
472 mov eax,1
473 shl eax,cl
474 dec eax
475 and eax,ebp
476 add eax,edx
477 mov edx, [esp+12]
478 mov eax, [edx+eax*4]
479 jmp L_dodist
480
481ALIGN 4
482L_clip_window:
483; 721 "inffast.S"
484 mov ecx,eax
485 mov eax, [esp+52]
486 neg ecx
487 mov esi, [esp+56]
488
489 cmp eax,edx
490 jb L_invalid_distance_too_far
491
492 add ecx,edx
493 cmp dword ptr [esp+48],0
494 jne L_wrap_around_window
495
496 sub eax,ecx
497 add esi,eax
498; 749 "inffast.S"
499 mov eax, [esp+24]
500 cmp eax,ecx
501 jbe L_do_copy1
502
503 sub eax,ecx
504 rep movsb
505 mov esi,edi
506 sub esi,edx
507 jmp L_do_copy1
508
509 cmp eax,ecx
510 jbe L_do_copy1
511
512 sub eax,ecx
513 rep movsb
514 mov esi,edi
515 sub esi,edx
516 jmp L_do_copy1
517
518L_wrap_around_window:
519; 793 "inffast.S"
520 mov eax, [esp+48]
521 cmp ecx,eax
522 jbe L_contiguous_in_window
523
524 add esi, [esp+52]
525 add esi,eax
526 sub esi,ecx
527 sub ecx,eax
528
529
530 mov eax, [esp+24]
531 cmp eax,ecx
532 jbe L_do_copy1
533
534 sub eax,ecx
535 rep movsb
536 mov esi, [esp+56]
537 mov ecx, [esp+48]
538 cmp eax,ecx
539 jbe L_do_copy1
540
541 sub eax,ecx
542 rep movsb
543 mov esi,edi
544 sub esi,edx
545 jmp L_do_copy1
546
547L_contiguous_in_window:
548; 836 "inffast.S"
549 add esi,eax
550 sub esi,ecx
551
552
553 mov eax, [esp+24]
554 cmp eax,ecx
555 jbe L_do_copy1
556
557 sub eax,ecx
558 rep movsb
559 mov esi,edi
560 sub esi,edx
561
562L_do_copy1:
563; 862 "inffast.S"
564 mov ecx,eax
565 rep movsb
566
567 mov esi, [esp+44]
568 jmp L_while_test
569; 878 "inffast.S"
570ALIGN 4
571L_init_mmx:
572 emms
573
574
575
576
577
578 movd mm0,ebp
579 mov ebp,ebx
580; 896 "inffast.S"
581 movd mm4,[esp+0]
582 movq mm3,mm4
583 movd mm5,[esp+4]
584 movq mm2,mm5
585 pxor mm1,mm1
586 mov ebx, [esp+8]
587 jmp L_do_loop_mmx
588
589ALIGN 4
590L_do_loop_mmx:
591 psrlq mm0,mm1
592
593 cmp ebp,32
594 ja L_get_length_code_mmx
595
596 movd mm6,ebp
597 movd mm7,[esi]
598 add esi,4
599 psllq mm7,mm6
600 add ebp,32
601 por mm0,mm7
602
603L_get_length_code_mmx:
604 pand mm4,mm0
605 movd eax,mm4
606 movq mm4,mm3
607 mov eax, [ebx+eax*4]
608
609L_dolen_mmx:
610 movzx ecx,ah
611 movd mm1,ecx
612 sub ebp,ecx
613
614 test al,al
615 jnz L_test_for_length_base_mmx
616
617 shr eax,16
618 stosb
619
620L_while_test_mmx:
621
622
623 cmp [esp+16],edi
624 jbe L_break_loop
625
626 cmp [esp+20],esi
627 ja L_do_loop_mmx
628 jmp L_break_loop
629
630L_test_for_length_base_mmx:
631
632 mov edx,eax
633 shr edx,16
634
635 test al,16
636 jz L_test_for_second_level_length_mmx
637 and eax,15
638 jz L_decode_distance_mmx
639
640 psrlq mm0,mm1
641 movd mm1,eax
642 movd ecx,mm0
643 sub ebp,eax
644 and ecx, [inflate_fast_mask+eax*4]
645 add edx,ecx
646
647L_decode_distance_mmx:
648 psrlq mm0,mm1
649
650 cmp ebp,32
651 ja L_get_dist_code_mmx
652
653 movd mm6,ebp
654 movd mm7,[esi]
655 add esi,4
656 psllq mm7,mm6
657 add ebp,32
658 por mm0,mm7
659
660L_get_dist_code_mmx:
661 mov ebx, [esp+12]
662 pand mm5,mm0
663 movd eax,mm5
664 movq mm5,mm2
665 mov eax, [ebx+eax*4]
666
667L_dodist_mmx:
668
669 movzx ecx,ah
670 mov ebx,eax
671 shr ebx,16
672 sub ebp,ecx
673 movd mm1,ecx
674
675 test al,16
676 jz L_test_for_second_level_dist_mmx
677 and eax,15
678 jz L_check_dist_one_mmx
679
680L_add_bits_to_dist_mmx:
681 psrlq mm0,mm1
682 movd mm1,eax
683 movd ecx,mm0
684 sub ebp,eax
685 and ecx, [inflate_fast_mask+eax*4]
686 add ebx,ecx
687
688L_check_window_mmx:
689 mov [esp+44],esi
690 mov eax,edi
691 sub eax, [esp+40]
692
693 cmp eax,ebx
694 jb L_clip_window_mmx
695
696 mov ecx,edx
697 mov esi,edi
698 sub esi,ebx
699
700 sub ecx,3
701 mov al, [esi]
702 mov [edi],al
703 mov al, [esi+1]
704 mov dl, [esi+2]
705 add esi,3
706 mov [edi+1],al
707 mov [edi+2],dl
708 add edi,3
709 rep movsb
710
711 mov esi, [esp+44]
712 mov ebx, [esp+8]
713 jmp L_while_test_mmx
714
715ALIGN 4
716L_check_dist_one_mmx:
717 cmp ebx,1
718 jne L_check_window_mmx
719 cmp [esp+40],edi
720 je L_check_window_mmx
721
722 dec edi
723 mov ecx,edx
724 mov al, [edi]
725 sub ecx,3
726
727 mov [edi+1],al
728 mov [edi+2],al
729 mov [edi+3],al
730 add edi,4
731 rep stosb
732
733 mov ebx, [esp+8]
734 jmp L_while_test_mmx
735
736ALIGN 4
737L_test_for_second_level_length_mmx:
738 test al,64
739 jnz L_test_for_end_of_block
740
741 and eax,15
742 psrlq mm0,mm1
743 movd ecx,mm0
744 and ecx, [inflate_fast_mask+eax*4]
745 add ecx,edx
746 mov eax, [ebx+ecx*4]
747 jmp L_dolen_mmx
748
749ALIGN 4
750L_test_for_second_level_dist_mmx:
751 test al,64
752 jnz L_invalid_distance_code
753
754 and eax,15
755 psrlq mm0,mm1
756 movd ecx,mm0
757 and ecx, [inflate_fast_mask+eax*4]
758 mov eax, [esp+12]
759 add ecx,ebx
760 mov eax, [eax+ecx*4]
761 jmp L_dodist_mmx
762
763ALIGN 4
764L_clip_window_mmx:
765
766 mov ecx,eax
767 mov eax, [esp+52]
768 neg ecx
769 mov esi, [esp+56]
770
771 cmp eax,ebx
772 jb L_invalid_distance_too_far
773
774 add ecx,ebx
775 cmp dword ptr [esp+48],0
776 jne L_wrap_around_window_mmx
777
778 sub eax,ecx
779 add esi,eax
780
781 cmp edx,ecx
782 jbe L_do_copy1_mmx
783
784 sub edx,ecx
785 rep movsb
786 mov esi,edi
787 sub esi,ebx
788 jmp L_do_copy1_mmx
789
790 cmp edx,ecx
791 jbe L_do_copy1_mmx
792
793 sub edx,ecx
794 rep movsb
795 mov esi,edi
796 sub esi,ebx
797 jmp L_do_copy1_mmx
798
799L_wrap_around_window_mmx:
800
801 mov eax, [esp+48]
802 cmp ecx,eax
803 jbe L_contiguous_in_window_mmx
804
805 add esi, [esp+52]
806 add esi,eax
807 sub esi,ecx
808 sub ecx,eax
809
810
811 cmp edx,ecx
812 jbe L_do_copy1_mmx
813
814 sub edx,ecx
815 rep movsb
816 mov esi, [esp+56]
817 mov ecx, [esp+48]
818 cmp edx,ecx
819 jbe L_do_copy1_mmx
820
821 sub edx,ecx
822 rep movsb
823 mov esi,edi
824 sub esi,ebx
825 jmp L_do_copy1_mmx
826
827L_contiguous_in_window_mmx:
828
829 add esi,eax
830 sub esi,ecx
831
832
833 cmp edx,ecx
834 jbe L_do_copy1_mmx
835
836 sub edx,ecx
837 rep movsb
838 mov esi,edi
839 sub esi,ebx
840
841L_do_copy1_mmx:
842
843
844 mov ecx,edx
845 rep movsb
846
847 mov esi, [esp+44]
848 mov ebx, [esp+8]
849 jmp L_while_test_mmx
850; 1174 "inffast.S"
851L_invalid_distance_code:
852
853
854
855
856
857 mov ecx, invalid_distance_code_msg
858 mov edx,26
859 jmp L_update_stream_state
860
861L_test_for_end_of_block:
862
863
864
865
866
867 test al,32
868 jz L_invalid_literal_length_code
869
870 mov ecx,0
871 mov edx,11
872 jmp L_update_stream_state
873
874L_invalid_literal_length_code:
875
876
877
878
879
880 mov ecx, invalid_literal_length_code_msg
881 mov edx,26
882 jmp L_update_stream_state
883
884L_invalid_distance_too_far:
885
886
887
888 mov esi, [esp+44]
889 mov ecx, invalid_distance_too_far_msg
890 mov edx,26
891 jmp L_update_stream_state
892
893L_update_stream_state:
894
895 mov eax, [esp+88]
896 test ecx,ecx
897 jz L_skip_msg
898 mov [eax+24],ecx
899L_skip_msg:
900 mov eax, [eax+28]
901 mov [eax+0],edx
902 jmp L_break_loop
903
904ALIGN 4
905L_break_loop:
906; 1243 "inffast.S"
907 cmp dword ptr [inflate_fast_use_mmx],2
908 jne L_update_next_in
909
910
911
912 mov ebx,ebp
913
914L_update_next_in:
915; 1266 "inffast.S"
916 mov eax, [esp+88]
917 mov ecx,ebx
918 mov edx, [eax+28]
919 shr ecx,3
920 sub esi,ecx
921 shl ecx,3
922 sub ebx,ecx
923 mov [eax+12],edi
924 mov [edx+48],ebx
925 mov ecx,ebx
926
927 lea ebx, [esp+28]
928 cmp [esp+20],ebx
929 jne L_buf_not_used
930
931 sub esi,ebx
932 mov ebx, [eax+0]
933 mov [esp+20],ebx
934 add esi,ebx
935 mov ebx, [eax+4]
936 sub ebx,11
937 add [esp+20],ebx
938
939L_buf_not_used:
940 mov [eax+0],esi
941
942 mov ebx,1
943 shl ebx,cl
944 dec ebx
945
946
947
948
949
950 cmp dword ptr [inflate_fast_use_mmx],2
951 jne L_update_hold
952
953
954
955 psrlq mm0,mm1
956 movd ebp,mm0
957
958 emms
959
960L_update_hold:
961
962
963
964 and ebp,ebx
965 mov [edx+44],ebp
966
967
968
969
970 mov ebx, [esp+20]
971 cmp ebx,esi
972 jbe L_last_is_smaller
973
974 sub ebx,esi
975 add ebx,11
976 mov [eax+4],ebx
977 jmp L_fixup_out
978L_last_is_smaller:
979 sub esi,ebx
980 neg esi
981 add esi,11
982 mov [eax+4],esi
983
984
985
986
987L_fixup_out:
988
989 mov ebx, [esp+16]
990 cmp ebx,edi
991 jbe L_end_is_smaller
992
993 sub ebx,edi
994 add ebx,257
995 mov [eax+16],ebx
996 jmp L_done
997L_end_is_smaller:
998 sub edi,ebx
999 neg edi
1000 add edi,257
1001 mov [eax+16],edi
1002
1003
1004
1005
1006
1007L_done:
1008 add esp,64
1009 popfd
1010 pop ebx
1011 pop ebp
1012 pop esi
1013 pop edi
1014 ret
1015
1016
1017
1018
1019_TEXT ends
1020end
diff --git a/contrib/vstudio/vc70_32/inffastAsm.obj b/contrib/vstudio/vc70_32/inffastAsm.obj
deleted file mode 100644
index 3855400..0000000
--- a/contrib/vstudio/vc70_32/inffastAsm.obj
+++ /dev/null
Binary files differ
diff --git a/contrib/vstudio/vc70_32/mkgvmt32.bat b/contrib/vstudio/vc70_32/mkgvmt32.bat
deleted file mode 100644
index 9c54db7..0000000
--- a/contrib/vstudio/vc70_32/mkgvmt32.bat
+++ /dev/null
@@ -1,2 +0,0 @@
1c:\masm611\bin\ml /coff /Zi /c /Flgvmat32.lst gvmat32.asm
2c:\masm611\bin\ml /coff /Zi /c /FlinffastAsm.lst inffastAsm.asm