Remove unused json code.
[sfrench/samba-autobuild/.git] / lib / zlib / contrib / masmx86 / inffas32.asm
1 ;/* inffas32.asm is a hand tuned assembler version of inffast.c -- fast decoding\r
2 ; *\r
3 ; * inffas32.asm is derivated from inffas86.c, with translation of assembly code\r
4 ; *\r
5 ; * Copyright (C) 1995-2003 Mark Adler\r
6 ; * For conditions of distribution and use, see copyright notice in zlib.h\r
7 ; *\r
8 ; * Copyright (C) 2003 Chris Anderson <christop@charm.net>\r
9 ; * Please use the copyright conditions above.\r
10 ; *\r
11 ; * Mar-13-2003 -- Most of this is derived from inffast.S which is derived from\r
12 ; * the gcc -S output of zlib-1.2.0/inffast.c.  Zlib-1.2.0 is in beta release at\r
13 ; * the moment.  I have successfully compiled and tested this code with gcc2.96,\r
14 ; * gcc3.2, icc5.0, msvc6.0.  It is very close to the speed of inffast.S\r
15 ; * compiled with gcc -DNO_MMX, but inffast.S is still faster on the P3 with MMX\r
16 ; * enabled.  I will attempt to merge the MMX code into this version.  Newer\r
17 ; * versions of this and inffast.S can be found at\r
18 ; * http://www.eetbeetee.com/zlib/ and http://www.charm.net/~christop/zlib/\r
19 ; * \r
20 ; * 2005 : modification by Gilles Vollant\r
21 ; */\r
22 ; For Visual C++ 4.x and higher and ML 6.x and higher\r
23 ;   ml.exe is in directory \MASM611C of Win95 DDK\r
24 ;   ml.exe is also distributed in http://www.masm32.com/masmdl.htm\r
25 ;    and in VC++2003 toolkit at http://msdn.microsoft.com/visualc/vctoolkit2003/\r
26 ;\r
27 ;\r
28 ;   compile with command line option\r
29 ;   ml  /coff /Zi /c /Flinffas32.lst inffas32.asm\r
30 \r
31 ;   if you define NO_GZIP (see inflate.h), compile with\r
32 ;   ml  /coff /Zi /c /Flinffas32.lst /DNO_GUNZIP inffas32.asm\r
33 \r
34 \r
35 ; zlib122sup is 0 fort zlib 1.2.2.1 and lower\r
36 ; zlib122sup is 8 fort zlib 1.2.2.2 and more (with addition of dmax and head \r
37 ;        in inflate_state in inflate.h)\r
38 zlib1222sup      equ    8\r
39 \r
40 \r
41 IFDEF GUNZIP\r
42   INFLATE_MODE_TYPE    equ 11\r
43   INFLATE_MODE_BAD     equ 26\r
44 ELSE\r
45   IFNDEF NO_GUNZIP\r
46     INFLATE_MODE_TYPE    equ 11\r
47     INFLATE_MODE_BAD     equ 26\r
48   ELSE\r
49     INFLATE_MODE_TYPE    equ 3\r
50     INFLATE_MODE_BAD     equ 17\r
51   ENDIF\r
52 ENDIF\r
53 \r
54 \r
55 ; 75 "inffast.S"\r
56 ;FILE "inffast.S"\r
57 \r
58 ;;;GLOBAL _inflate_fast\r
59 \r
60 ;;;SECTION .text\r
61 \r
62 \r
63 \r
64         .586p\r
65         .mmx\r
66 \r
67         name    inflate_fast_x86\r
68         .MODEL  FLAT\r
69 \r
70 _DATA                   segment\r
71 inflate_fast_use_mmx:\r
72         dd      1\r
73 \r
74 \r
75 _TEXT                   segment\r
76 PUBLIC _inflate_fast\r
77 \r
78 ALIGN 4\r
79 _inflate_fast:\r
80         jmp inflate_fast_entry\r
81 \r
82 \r
83 \r
84 ALIGN 4\r
85         db      'Fast decoding Code from Chris Anderson'\r
86         db      0\r
87 \r
88 ALIGN 4\r
89 invalid_literal_length_code_msg:\r
90         db      'invalid literal/length code'\r
91         db      0\r
92 \r
93 ALIGN 4\r
94 invalid_distance_code_msg:\r
95         db      'invalid distance code'\r
96         db      0\r
97 \r
98 ALIGN 4\r
99 invalid_distance_too_far_msg:\r
100         db      'invalid distance too far back'\r
101         db      0\r
102 \r
103 \r
104 ALIGN 4\r
105 inflate_fast_mask:\r
106 dd      0\r
107 dd      1\r
108 dd      3\r
109 dd      7\r
110 dd      15\r
111 dd      31\r
112 dd      63\r
113 dd      127\r
114 dd      255\r
115 dd      511\r
116 dd      1023\r
117 dd      2047\r
118 dd      4095\r
119 dd      8191\r
120 dd      16383\r
121 dd      32767\r
122 dd      65535\r
123 dd      131071\r
124 dd      262143\r
125 dd      524287\r
126 dd      1048575\r
127 dd      2097151\r
128 dd      4194303\r
129 dd      8388607\r
130 dd      16777215\r
131 dd      33554431\r
132 dd      67108863\r
133 dd      134217727\r
134 dd      268435455\r
135 dd      536870911\r
136 dd      1073741823\r
137 dd      2147483647\r
138 dd      4294967295\r
139 \r
140 \r
141 mode_state       equ    0       ;/* state->mode */\r
142 wsize_state      equ    (32+zlib1222sup)        ;/* state->wsize */\r
143 write_state      equ    (36+4+zlib1222sup)      ;/* state->write */\r
144 window_state     equ    (40+4+zlib1222sup)      ;/* state->window */\r
145 hold_state       equ    (44+4+zlib1222sup)      ;/* state->hold */\r
146 bits_state       equ    (48+4+zlib1222sup)      ;/* state->bits */\r
147 lencode_state    equ    (64+4+zlib1222sup)      ;/* state->lencode */\r
148 distcode_state   equ    (68+4+zlib1222sup)      ;/* state->distcode */\r
149 lenbits_state    equ    (72+4+zlib1222sup)      ;/* state->lenbits */\r
150 distbits_state   equ    (76+4+zlib1222sup)      ;/* state->distbits */\r
151 \r
152 \r
153 ;;SECTION .text\r
154 ; 205 "inffast.S"\r
155 ;GLOBAL inflate_fast_use_mmx\r
156 \r
157 ;SECTION .data\r
158 \r
159 \r
160 ; GLOBAL inflate_fast_use_mmx:object\r
161 ;.size inflate_fast_use_mmx, 4\r
162 ; 226 "inffast.S"\r
163 ;SECTION .text\r
164 \r
165 ALIGN 4\r
166 inflate_fast_entry:\r
167         push  edi\r
168         push  esi\r
169         push  ebp\r
170         push  ebx\r
171         pushfd\r
172         sub  esp,64\r
173         cld\r
174 \r
175 \r
176 \r
177 \r
178         mov  esi, [esp+88]\r
179         mov  edi, [esi+28]\r
180 \r
181 \r
182 \r
183 \r
184 \r
185 \r
186 \r
187         mov  edx, [esi+4]\r
188         mov  eax, [esi+0]\r
189 \r
190         add  edx,eax\r
191         sub  edx,11\r
192 \r
193         mov  [esp+44],eax\r
194         mov  [esp+20],edx\r
195 \r
196         mov  ebp, [esp+92]\r
197         mov  ecx, [esi+16]\r
198         mov  ebx, [esi+12]\r
199 \r
200         sub  ebp,ecx\r
201         neg  ebp\r
202         add  ebp,ebx\r
203 \r
204         sub  ecx,257\r
205         add  ecx,ebx\r
206 \r
207         mov  [esp+60],ebx\r
208         mov  [esp+40],ebp\r
209         mov  [esp+16],ecx\r
210 ; 285 "inffast.S"\r
211         mov  eax, [edi+lencode_state]\r
212         mov  ecx, [edi+distcode_state]\r
213 \r
214         mov  [esp+8],eax\r
215         mov  [esp+12],ecx\r
216 \r
217         mov  eax,1\r
218         mov  ecx, [edi+lenbits_state]\r
219         shl  eax,cl\r
220         dec  eax\r
221         mov  [esp+0],eax\r
222 \r
223         mov  eax,1\r
224         mov  ecx, [edi+distbits_state]\r
225         shl  eax,cl\r
226         dec  eax\r
227         mov  [esp+4],eax\r
228 \r
229         mov  eax, [edi+wsize_state]\r
230         mov  ecx, [edi+write_state]\r
231         mov  edx, [edi+window_state]\r
232 \r
233         mov  [esp+52],eax\r
234         mov  [esp+48],ecx\r
235         mov  [esp+56],edx\r
236 \r
237         mov  ebp, [edi+hold_state]\r
238         mov  ebx, [edi+bits_state]\r
239 ; 321 "inffast.S"\r
240         mov  esi, [esp+44]\r
241         mov  ecx, [esp+20]\r
242         cmp  ecx,esi\r
243         ja   L_align_long\r
244 \r
245         add  ecx,11\r
246         sub  ecx,esi\r
247         mov  eax,12\r
248         sub  eax,ecx\r
249         lea  edi, [esp+28]\r
250         rep movsb\r
251         mov  ecx,eax\r
252         xor  eax,eax\r
253         rep stosb\r
254         lea  esi, [esp+28]\r
255         mov  [esp+20],esi\r
256         jmp  L_is_aligned\r
257 \r
258 \r
259 L_align_long:\r
260         test  esi,3\r
261         jz   L_is_aligned\r
262         xor  eax,eax\r
263         mov  al, [esi]\r
264         inc  esi\r
265         mov  ecx,ebx\r
266         add  ebx,8\r
267         shl  eax,cl\r
268         or  ebp,eax\r
269         jmp L_align_long\r
270 \r
271 L_is_aligned:\r
272         mov  edi, [esp+60]\r
273 ; 366 "inffast.S"\r
274 L_check_mmx:\r
275         cmp  dword ptr [inflate_fast_use_mmx],2\r
276         je   L_init_mmx\r
277         ja   L_do_loop\r
278 \r
279         push  eax\r
280         push  ebx\r
281         push  ecx\r
282         push  edx\r
283         pushfd\r
284         mov  eax, [esp]\r
285         xor  dword ptr [esp],0200000h\r
286 \r
287 \r
288 \r
289 \r
290         popfd\r
291         pushfd\r
292         pop  edx\r
293         xor  edx,eax\r
294         jz   L_dont_use_mmx\r
295         xor  eax,eax\r
296         cpuid\r
297         cmp  ebx,0756e6547h\r
298         jne  L_dont_use_mmx\r
299         cmp  ecx,06c65746eh\r
300         jne  L_dont_use_mmx\r
301         cmp  edx,049656e69h\r
302         jne  L_dont_use_mmx\r
303         mov  eax,1\r
304         cpuid\r
305         shr  eax,8\r
306         and  eax,15\r
307         cmp  eax,6\r
308         jne  L_dont_use_mmx\r
309         test  edx,0800000h\r
310         jnz  L_use_mmx\r
311         jmp  L_dont_use_mmx\r
312 L_use_mmx:\r
313         mov  dword ptr [inflate_fast_use_mmx],2\r
314         jmp  L_check_mmx_pop\r
315 L_dont_use_mmx:\r
316         mov  dword ptr [inflate_fast_use_mmx],3\r
317 L_check_mmx_pop:\r
318         pop  edx\r
319         pop  ecx\r
320         pop  ebx\r
321         pop  eax\r
322         jmp  L_check_mmx\r
323 ; 426 "inffast.S"\r
324 ALIGN 4\r
325 L_do_loop:\r
326 ; 437 "inffast.S"\r
327         cmp  bl,15\r
328         ja   L_get_length_code\r
329 \r
330         xor  eax,eax\r
331         lodsw\r
332         mov  cl,bl\r
333         add  bl,16\r
334         shl  eax,cl\r
335         or  ebp,eax\r
336 \r
337 L_get_length_code:\r
338         mov  edx, [esp+0]\r
339         mov  ecx, [esp+8]\r
340         and  edx,ebp\r
341         mov  eax, [ecx+edx*4]\r
342 \r
343 L_dolen:\r
344 \r
345 \r
346 \r
347 \r
348 \r
349 \r
350         mov  cl,ah\r
351         sub  bl,ah\r
352         shr  ebp,cl\r
353 \r
354 \r
355 \r
356 \r
357 \r
358 \r
359         test  al,al\r
360         jnz   L_test_for_length_base\r
361 \r
362         shr  eax,16\r
363         stosb\r
364 \r
365 L_while_test:\r
366 \r
367 \r
368         cmp  [esp+16],edi\r
369         jbe  L_break_loop\r
370 \r
371         cmp  [esp+20],esi\r
372         ja   L_do_loop\r
373         jmp  L_break_loop\r
374 \r
375 L_test_for_length_base:\r
376 ; 502 "inffast.S"\r
377         mov  edx,eax\r
378         shr  edx,16\r
379         mov  cl,al\r
380 \r
381         test  al,16\r
382         jz   L_test_for_second_level_length\r
383         and  cl,15\r
384         jz   L_save_len\r
385         cmp  bl,cl\r
386         jae  L_add_bits_to_len\r
387 \r
388         mov  ch,cl\r
389         xor  eax,eax\r
390         lodsw\r
391         mov  cl,bl\r
392         add  bl,16\r
393         shl  eax,cl\r
394         or  ebp,eax\r
395         mov  cl,ch\r
396 \r
397 L_add_bits_to_len:\r
398         mov  eax,1\r
399         shl  eax,cl\r
400         dec  eax\r
401         sub  bl,cl\r
402         and  eax,ebp\r
403         shr  ebp,cl\r
404         add  edx,eax\r
405 \r
406 L_save_len:\r
407         mov  [esp+24],edx\r
408 \r
409 \r
410 L_decode_distance:\r
411 ; 549 "inffast.S"\r
412         cmp  bl,15\r
413         ja   L_get_distance_code\r
414 \r
415         xor  eax,eax\r
416         lodsw\r
417         mov  cl,bl\r
418         add  bl,16\r
419         shl  eax,cl\r
420         or  ebp,eax\r
421 \r
422 L_get_distance_code:\r
423         mov  edx, [esp+4]\r
424         mov  ecx, [esp+12]\r
425         and  edx,ebp\r
426         mov  eax, [ecx+edx*4]\r
427 \r
428 \r
429 L_dodist:\r
430         mov  edx,eax\r
431         shr  edx,16\r
432         mov  cl,ah\r
433         sub  bl,ah\r
434         shr  ebp,cl\r
435 ; 584 "inffast.S"\r
436         mov  cl,al\r
437 \r
438         test  al,16\r
439         jz  L_test_for_second_level_dist\r
440         and  cl,15\r
441         jz  L_check_dist_one\r
442         cmp  bl,cl\r
443         jae  L_add_bits_to_dist\r
444 \r
445         mov  ch,cl\r
446         xor  eax,eax\r
447         lodsw\r
448         mov  cl,bl\r
449         add  bl,16\r
450         shl  eax,cl\r
451         or  ebp,eax\r
452         mov  cl,ch\r
453 \r
454 L_add_bits_to_dist:\r
455         mov  eax,1\r
456         shl  eax,cl\r
457         dec  eax\r
458         sub  bl,cl\r
459         and  eax,ebp\r
460         shr  ebp,cl\r
461         add  edx,eax\r
462         jmp  L_check_window\r
463 \r
464 L_check_window:\r
465 ; 625 "inffast.S"\r
466         mov  [esp+44],esi\r
467         mov  eax,edi\r
468         sub  eax, [esp+40]\r
469 \r
470         cmp  eax,edx\r
471         jb   L_clip_window\r
472 \r
473         mov  ecx, [esp+24]\r
474         mov  esi,edi\r
475         sub  esi,edx\r
476 \r
477         sub  ecx,3\r
478         mov  al, [esi]\r
479         mov  [edi],al\r
480         mov  al, [esi+1]\r
481         mov  dl, [esi+2]\r
482         add  esi,3\r
483         mov  [edi+1],al\r
484         mov  [edi+2],dl\r
485         add  edi,3\r
486         rep movsb\r
487 \r
488         mov  esi, [esp+44]\r
489         jmp  L_while_test\r
490 \r
491 ALIGN 4\r
492 L_check_dist_one:\r
493         cmp  edx,1\r
494         jne  L_check_window\r
495         cmp  [esp+40],edi\r
496         je  L_check_window\r
497 \r
498         dec  edi\r
499         mov  ecx, [esp+24]\r
500         mov  al, [edi]\r
501         sub  ecx,3\r
502 \r
503         mov  [edi+1],al\r
504         mov  [edi+2],al\r
505         mov  [edi+3],al\r
506         add  edi,4\r
507         rep stosb\r
508 \r
509         jmp  L_while_test\r
510 \r
511 ALIGN 4\r
512 L_test_for_second_level_length:\r
513 \r
514 \r
515 \r
516 \r
517         test  al,64\r
518         jnz   L_test_for_end_of_block\r
519 \r
520         mov  eax,1\r
521         shl  eax,cl\r
522         dec  eax\r
523         and  eax,ebp\r
524         add  eax,edx\r
525         mov  edx, [esp+8]\r
526         mov  eax, [edx+eax*4]\r
527         jmp  L_dolen\r
528 \r
529 ALIGN 4\r
530 L_test_for_second_level_dist:\r
531 \r
532 \r
533 \r
534 \r
535         test  al,64\r
536         jnz   L_invalid_distance_code\r
537 \r
538         mov  eax,1\r
539         shl  eax,cl\r
540         dec  eax\r
541         and  eax,ebp\r
542         add  eax,edx\r
543         mov  edx, [esp+12]\r
544         mov  eax, [edx+eax*4]\r
545         jmp  L_dodist\r
546 \r
547 ALIGN 4\r
548 L_clip_window:\r
549 ; 721 "inffast.S"\r
550         mov  ecx,eax\r
551         mov  eax, [esp+52]\r
552         neg  ecx\r
553         mov  esi, [esp+56]\r
554 \r
555         cmp  eax,edx\r
556         jb   L_invalid_distance_too_far\r
557 \r
558         add  ecx,edx\r
559         cmp  dword ptr [esp+48],0\r
560         jne  L_wrap_around_window\r
561 \r
562         sub  eax,ecx\r
563         add  esi,eax\r
564 ; 749 "inffast.S"\r
565         mov  eax, [esp+24]\r
566         cmp  eax,ecx\r
567         jbe  L_do_copy1\r
568 \r
569         sub  eax,ecx\r
570         rep movsb\r
571         mov  esi,edi\r
572         sub  esi,edx\r
573         jmp  L_do_copy1\r
574 \r
575         cmp  eax,ecx\r
576         jbe  L_do_copy1\r
577 \r
578         sub  eax,ecx\r
579         rep movsb\r
580         mov  esi,edi\r
581         sub  esi,edx\r
582         jmp  L_do_copy1\r
583 \r
584 L_wrap_around_window:\r
585 ; 793 "inffast.S"\r
586         mov  eax, [esp+48]\r
587         cmp  ecx,eax\r
588         jbe  L_contiguous_in_window\r
589 \r
590         add  esi, [esp+52]\r
591         add  esi,eax\r
592         sub  esi,ecx\r
593         sub  ecx,eax\r
594 \r
595 \r
596         mov  eax, [esp+24]\r
597         cmp  eax,ecx\r
598         jbe  L_do_copy1\r
599 \r
600         sub  eax,ecx\r
601         rep movsb\r
602         mov  esi, [esp+56]\r
603         mov  ecx, [esp+48]\r
604         cmp  eax,ecx\r
605         jbe  L_do_copy1\r
606 \r
607         sub  eax,ecx\r
608         rep movsb\r
609         mov  esi,edi\r
610         sub  esi,edx\r
611         jmp  L_do_copy1\r
612 \r
613 L_contiguous_in_window:\r
614 ; 836 "inffast.S"\r
615         add  esi,eax\r
616         sub  esi,ecx\r
617 \r
618 \r
619         mov  eax, [esp+24]\r
620         cmp  eax,ecx\r
621         jbe  L_do_copy1\r
622 \r
623         sub  eax,ecx\r
624         rep movsb\r
625         mov  esi,edi\r
626         sub  esi,edx\r
627 \r
628 L_do_copy1:\r
629 ; 862 "inffast.S"\r
630         mov  ecx,eax\r
631         rep movsb\r
632 \r
633         mov  esi, [esp+44]\r
634         jmp  L_while_test\r
635 ; 878 "inffast.S"\r
636 ALIGN 4\r
637 L_init_mmx:\r
638         emms\r
639 \r
640 \r
641 \r
642 \r
643 \r
644         movd mm0,ebp\r
645         mov  ebp,ebx\r
646 ; 896 "inffast.S"\r
647         movd mm4,[esp+0]\r
648         movq mm3,mm4\r
649         movd mm5,[esp+4]\r
650         movq mm2,mm5\r
651         pxor mm1,mm1\r
652         mov  ebx, [esp+8]\r
653         jmp  L_do_loop_mmx\r
654 \r
655 ALIGN 4\r
656 L_do_loop_mmx:\r
657         psrlq mm0,mm1\r
658 \r
659         cmp  ebp,32\r
660         ja  L_get_length_code_mmx\r
661 \r
662         movd mm6,ebp\r
663         movd mm7,[esi]\r
664         add  esi,4\r
665         psllq mm7,mm6\r
666         add  ebp,32\r
667         por mm0,mm7\r
668 \r
669 L_get_length_code_mmx:\r
670         pand mm4,mm0\r
671         movd eax,mm4\r
672         movq mm4,mm3\r
673         mov  eax, [ebx+eax*4]\r
674 \r
675 L_dolen_mmx:\r
676         movzx  ecx,ah\r
677         movd mm1,ecx\r
678         sub  ebp,ecx\r
679 \r
680         test  al,al\r
681         jnz L_test_for_length_base_mmx\r
682 \r
683         shr  eax,16\r
684         stosb\r
685 \r
686 L_while_test_mmx:\r
687 \r
688 \r
689         cmp  [esp+16],edi\r
690         jbe L_break_loop\r
691 \r
692         cmp  [esp+20],esi\r
693         ja L_do_loop_mmx\r
694         jmp L_break_loop\r
695 \r
696 L_test_for_length_base_mmx:\r
697 \r
698         mov  edx,eax\r
699         shr  edx,16\r
700 \r
701         test  al,16\r
702         jz  L_test_for_second_level_length_mmx\r
703         and  eax,15\r
704         jz L_decode_distance_mmx\r
705 \r
706         psrlq mm0,mm1\r
707         movd mm1,eax\r
708         movd ecx,mm0\r
709         sub  ebp,eax\r
710         and  ecx, [inflate_fast_mask+eax*4]\r
711         add  edx,ecx\r
712 \r
713 L_decode_distance_mmx:\r
714         psrlq mm0,mm1\r
715 \r
716         cmp  ebp,32\r
717         ja L_get_dist_code_mmx\r
718 \r
719         movd mm6,ebp\r
720         movd mm7,[esi]\r
721         add  esi,4\r
722         psllq mm7,mm6\r
723         add  ebp,32\r
724         por mm0,mm7\r
725 \r
726 L_get_dist_code_mmx:\r
727         mov  ebx, [esp+12]\r
728         pand mm5,mm0\r
729         movd eax,mm5\r
730         movq mm5,mm2\r
731         mov  eax, [ebx+eax*4]\r
732 \r
733 L_dodist_mmx:\r
734 \r
735         movzx  ecx,ah\r
736         mov  ebx,eax\r
737         shr  ebx,16\r
738         sub  ebp,ecx\r
739         movd mm1,ecx\r
740 \r
741         test  al,16\r
742         jz L_test_for_second_level_dist_mmx\r
743         and  eax,15\r
744         jz L_check_dist_one_mmx\r
745 \r
746 L_add_bits_to_dist_mmx:\r
747         psrlq mm0,mm1\r
748         movd mm1,eax\r
749         movd ecx,mm0\r
750         sub  ebp,eax\r
751         and  ecx, [inflate_fast_mask+eax*4]\r
752         add  ebx,ecx\r
753 \r
754 L_check_window_mmx:\r
755         mov  [esp+44],esi\r
756         mov  eax,edi\r
757         sub  eax, [esp+40]\r
758 \r
759         cmp  eax,ebx\r
760         jb L_clip_window_mmx\r
761 \r
762         mov  ecx,edx\r
763         mov  esi,edi\r
764         sub  esi,ebx\r
765 \r
766         sub  ecx,3\r
767         mov  al, [esi]\r
768         mov  [edi],al\r
769         mov  al, [esi+1]\r
770         mov  dl, [esi+2]\r
771         add  esi,3\r
772         mov  [edi+1],al\r
773         mov  [edi+2],dl\r
774         add  edi,3\r
775         rep movsb\r
776 \r
777         mov  esi, [esp+44]\r
778         mov  ebx, [esp+8]\r
779         jmp  L_while_test_mmx\r
780 \r
781 ALIGN 4\r
782 L_check_dist_one_mmx:\r
783         cmp  ebx,1\r
784         jne  L_check_window_mmx\r
785         cmp  [esp+40],edi\r
786         je   L_check_window_mmx\r
787 \r
788         dec  edi\r
789         mov  ecx,edx\r
790         mov  al, [edi]\r
791         sub  ecx,3\r
792 \r
793         mov  [edi+1],al\r
794         mov  [edi+2],al\r
795         mov  [edi+3],al\r
796         add  edi,4\r
797         rep stosb\r
798 \r
799         mov  ebx, [esp+8]\r
800         jmp  L_while_test_mmx\r
801 \r
802 ALIGN 4\r
803 L_test_for_second_level_length_mmx:\r
804         test  al,64\r
805         jnz L_test_for_end_of_block\r
806 \r
807         and  eax,15\r
808         psrlq mm0,mm1\r
809         movd ecx,mm0\r
810         and  ecx, [inflate_fast_mask+eax*4]\r
811         add  ecx,edx\r
812         mov  eax, [ebx+ecx*4]\r
813         jmp L_dolen_mmx\r
814 \r
815 ALIGN 4\r
816 L_test_for_second_level_dist_mmx:\r
817         test  al,64\r
818         jnz L_invalid_distance_code\r
819 \r
820         and  eax,15\r
821         psrlq mm0,mm1\r
822         movd ecx,mm0\r
823         and  ecx, [inflate_fast_mask+eax*4]\r
824         mov  eax, [esp+12]\r
825         add  ecx,ebx\r
826         mov  eax, [eax+ecx*4]\r
827         jmp  L_dodist_mmx\r
828 \r
829 ALIGN 4\r
830 L_clip_window_mmx:\r
831 \r
832         mov  ecx,eax\r
833         mov  eax, [esp+52]\r
834         neg  ecx\r
835         mov  esi, [esp+56]\r
836 \r
837         cmp  eax,ebx\r
838         jb  L_invalid_distance_too_far\r
839 \r
840         add  ecx,ebx\r
841         cmp  dword ptr [esp+48],0\r
842         jne  L_wrap_around_window_mmx\r
843 \r
844         sub  eax,ecx\r
845         add  esi,eax\r
846 \r
847         cmp  edx,ecx\r
848         jbe  L_do_copy1_mmx\r
849 \r
850         sub  edx,ecx\r
851         rep movsb\r
852         mov  esi,edi\r
853         sub  esi,ebx\r
854         jmp  L_do_copy1_mmx\r
855 \r
856         cmp  edx,ecx\r
857         jbe  L_do_copy1_mmx\r
858 \r
859         sub  edx,ecx\r
860         rep movsb\r
861         mov  esi,edi\r
862         sub  esi,ebx\r
863         jmp  L_do_copy1_mmx\r
864 \r
865 L_wrap_around_window_mmx:\r
866 \r
867         mov  eax, [esp+48]\r
868         cmp  ecx,eax\r
869         jbe  L_contiguous_in_window_mmx\r
870 \r
871         add  esi, [esp+52]\r
872         add  esi,eax\r
873         sub  esi,ecx\r
874         sub  ecx,eax\r
875 \r
876 \r
877         cmp  edx,ecx\r
878         jbe  L_do_copy1_mmx\r
879 \r
880         sub  edx,ecx\r
881         rep movsb\r
882         mov  esi, [esp+56]\r
883         mov  ecx, [esp+48]\r
884         cmp  edx,ecx\r
885         jbe  L_do_copy1_mmx\r
886 \r
887         sub  edx,ecx\r
888         rep movsb\r
889         mov  esi,edi\r
890         sub  esi,ebx\r
891         jmp  L_do_copy1_mmx\r
892 \r
893 L_contiguous_in_window_mmx:\r
894 \r
895         add  esi,eax\r
896         sub  esi,ecx\r
897 \r
898 \r
899         cmp  edx,ecx\r
900         jbe  L_do_copy1_mmx\r
901 \r
902         sub  edx,ecx\r
903         rep movsb\r
904         mov  esi,edi\r
905         sub  esi,ebx\r
906 \r
907 L_do_copy1_mmx:\r
908 \r
909 \r
910         mov  ecx,edx\r
911         rep movsb\r
912 \r
913         mov  esi, [esp+44]\r
914         mov  ebx, [esp+8]\r
915         jmp  L_while_test_mmx\r
916 ; 1174 "inffast.S"\r
917 L_invalid_distance_code:\r
918 \r
919 \r
920 \r
921 \r
922 \r
923         mov  ecx, invalid_distance_code_msg\r
924         mov  edx,INFLATE_MODE_BAD\r
925         jmp  L_update_stream_state\r
926 \r
927 L_test_for_end_of_block:\r
928 \r
929 \r
930 \r
931 \r
932 \r
933         test  al,32\r
934         jz  L_invalid_literal_length_code\r
935 \r
936         mov  ecx,0\r
937         mov  edx,INFLATE_MODE_TYPE\r
938         jmp  L_update_stream_state\r
939 \r
940 L_invalid_literal_length_code:\r
941 \r
942 \r
943 \r
944 \r
945 \r
946         mov  ecx, invalid_literal_length_code_msg\r
947         mov  edx,INFLATE_MODE_BAD\r
948         jmp  L_update_stream_state\r
949 \r
950 L_invalid_distance_too_far:\r
951 \r
952 \r
953 \r
954         mov  esi, [esp+44]\r
955         mov  ecx, invalid_distance_too_far_msg\r
956         mov  edx,INFLATE_MODE_BAD\r
957         jmp  L_update_stream_state\r
958 \r
959 L_update_stream_state:\r
960 \r
961         mov  eax, [esp+88]\r
962         test  ecx,ecx\r
963         jz  L_skip_msg\r
964         mov  [eax+24],ecx\r
965 L_skip_msg:\r
966         mov  eax, [eax+28]\r
967         mov  [eax+mode_state],edx\r
968         jmp  L_break_loop\r
969 \r
970 ALIGN 4\r
971 L_break_loop:\r
972 ; 1243 "inffast.S"\r
973         cmp  dword ptr [inflate_fast_use_mmx],2\r
974         jne  L_update_next_in\r
975 \r
976 \r
977 \r
978         mov  ebx,ebp\r
979 \r
980 L_update_next_in:\r
981 ; 1266 "inffast.S"\r
982         mov  eax, [esp+88]\r
983         mov  ecx,ebx\r
984         mov  edx, [eax+28]\r
985         shr  ecx,3\r
986         sub  esi,ecx\r
987         shl  ecx,3\r
988         sub  ebx,ecx\r
989         mov  [eax+12],edi\r
990         mov  [edx+bits_state],ebx\r
991         mov  ecx,ebx\r
992 \r
993         lea  ebx, [esp+28]\r
994         cmp  [esp+20],ebx\r
995         jne  L_buf_not_used\r
996 \r
997         sub  esi,ebx\r
998         mov  ebx, [eax+0]\r
999         mov  [esp+20],ebx\r
1000         add  esi,ebx\r
1001         mov  ebx, [eax+4]\r
1002         sub  ebx,11\r
1003         add  [esp+20],ebx\r
1004 \r
1005 L_buf_not_used:\r
1006         mov  [eax+0],esi\r
1007 \r
1008         mov  ebx,1\r
1009         shl  ebx,cl\r
1010         dec  ebx\r
1011 \r
1012 \r
1013 \r
1014 \r
1015 \r
1016         cmp  dword ptr [inflate_fast_use_mmx],2\r
1017         jne  L_update_hold\r
1018 \r
1019 \r
1020 \r
1021         psrlq mm0,mm1\r
1022         movd ebp,mm0\r
1023 \r
1024         emms\r
1025 \r
1026 L_update_hold:\r
1027 \r
1028 \r
1029 \r
1030         and  ebp,ebx\r
1031         mov  [edx+hold_state],ebp\r
1032 \r
1033 \r
1034 \r
1035 \r
1036         mov  ebx, [esp+20]\r
1037         cmp  ebx,esi\r
1038         jbe  L_last_is_smaller\r
1039 \r
1040         sub  ebx,esi\r
1041         add  ebx,11\r
1042         mov  [eax+4],ebx\r
1043         jmp  L_fixup_out\r
1044 L_last_is_smaller:\r
1045         sub  esi,ebx\r
1046         neg  esi\r
1047         add  esi,11\r
1048         mov  [eax+4],esi\r
1049 \r
1050 \r
1051 \r
1052 \r
1053 L_fixup_out:\r
1054 \r
1055         mov  ebx, [esp+16]\r
1056         cmp  ebx,edi\r
1057         jbe  L_end_is_smaller\r
1058 \r
1059         sub  ebx,edi\r
1060         add  ebx,257\r
1061         mov  [eax+16],ebx\r
1062         jmp  L_done\r
1063 L_end_is_smaller:\r
1064         sub  edi,ebx\r
1065         neg  edi\r
1066         add  edi,257\r
1067         mov  [eax+16],edi\r
1068 \r
1069 \r
1070 \r
1071 \r
1072 \r
1073 L_done:\r
1074         add  esp,64\r
1075         popfd\r
1076         pop  ebx\r
1077         pop  ebp\r
1078         pop  esi\r
1079         pop  edi\r
1080         ret\r
1081 \r
1082 _TEXT   ends\r
1083 end\r