summaryrefslogtreecommitdiff
path: root/contrib/vstudio/vc70_32/inffastAsm.asm
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/vstudio/vc70_32/inffastAsm.asm')
-rw-r--r--contrib/vstudio/vc70_32/inffastAsm.asm1020
1 files changed, 1020 insertions, 0 deletions
diff --git a/contrib/vstudio/vc70_32/inffastAsm.asm b/contrib/vstudio/vc70_32/inffastAsm.asm
new file mode 100644
index 0000000..f4b6a56
--- /dev/null
+++ b/contrib/vstudio/vc70_32/inffastAsm.asm
@@ -0,0 +1,1020 @@
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