123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- #if !defined(USE_ZLIB) && !defined(CRC_TABLE_ONLY)
- #if defined(NO_UNDERLINE) || defined(__ELF__)
- # define _crc32 crc32
- # define _get_crc_table get_crc_table
- #endif
- #ifndef ALIGNMENT
- # define ALIGNMENT .align 4,0x90
- #endif
- #if defined(i386) || defined(_i386) || defined(_I386) || defined(__i386)
- .file "crc_i386.S"
- #if !defined(PRE_686) && !defined(__686)
-
- # define __686
- #endif
- #if defined(NO_STD_STACKFRAME) && defined(USE_STD_STACKFRAME)
- # undef USE_STACKFRAME
- #else
-
- # ifndef USE_STD_STACKFRAME
- # define USE_STD_STACKFRAME
- # endif
- #endif
- #ifdef USE_STD_STACKFRAME
- # define _STD_ENTRY pushl %ebp ; movl %esp,%ebp
- # define arg1 8(%ebp)
- # define arg2 12(%ebp)
- # define arg3 16(%ebp)
- # define _STD_LEAVE popl %ebp
- #else
- # define _STD_ENTRY
- # define arg1 24(%esp)
- # define arg2 28(%esp)
- # define arg3 32(%esp)
- # define _STD_LEAVE
- #endif
- #ifndef __686
- #define Do_CRC \
- movb %al, %bl ;\
- shrl $8, %eax ;\
- xorl (%edi, %ebx, 4), %eax ;
- #else
- #define Do_CRC \
- movzbl %al, %ebx ;\
- shrl $8, %eax ;\
- xorl (%edi, %ebx, 4), %eax ;
- #endif
- #define Do_CRC_byte \
- xorb (%esi), %al ;\
- incl %esi ;\
- Do_CRC
- #define Do_CRC_byteof(ofs) \
- xorb ofs(%esi), %al ;\
- incl %esi ;\
- Do_CRC
- #ifndef NO_32_BIT_LOADS
- # ifdef IZ_CRCOPTIM_UNFOLDTBL
-
- # define SavLen arg3
- # define UpdCRC_lword \
- movzbl %al, %ebx ; \
- movl 3072(%edi,%ebx,4), %edx ; \
- movzbl %ah, %ebx ; \
- shrl $16, %eax ; \
- xor 2048(%edi,%ebx,4), %edx ; \
- movzbl %al, %ebx ; \
- shrl $8,%eax ; \
- xorl 1024(%edi,%ebx,4), %edx ; \
- movl (%edi,%eax,4), %eax ; \
- xorl %edx,%eax ;
- # define UpdCRC_lword_sh(dwPtrIncr) \
- movzbl %al, %ebx ; \
- movl 3072(%edi,%ebx,4), %edx ; \
- movzbl %ah, %ebx ; \
- shrl $16, %eax ; \
- xor 2048(%edi,%ebx,4), %edx ; \
- movzbl %al, %ebx ; \
- addl $4*(dwPtrIncr), %esi ;\
- shrl $8,%eax ; \
- xorl 1024(%edi,%ebx,4), %edx ; \
- movl (%edi,%eax,4),%eax ; \
- xorl %edx,%eax ;
- # else
-
- # define SavLen %edx
- # define UpdCRC_lword \
- Do_CRC \
- Do_CRC \
- Do_CRC \
- Do_CRC
- # define UpdCRC_lword_sh(dwPtrIncr) \
- Do_CRC \
- Do_CRC \
- addl $4*(dwPtrIncr), %esi ;\
- Do_CRC \
- Do_CRC
- # endif
- #define Do_CRC_lword \
- xorl (%esi), %eax ;\
- UpdCRC_lword_sh(1)
- #define Do_CRC_4lword \
- xorl (%esi), %eax ;\
- UpdCRC_lword \
- xorl 4(%esi), %eax ;\
- UpdCRC_lword \
- xorl 8(%esi), %eax ;\
- UpdCRC_lword \
- xorl 12(%esi), %eax ;\
- UpdCRC_lword_sh(4)
- #endif
- .text
- .globl _crc32
- _crc32:
- _STD_ENTRY
- pushl %edi
- pushl %esi
- pushl %ebx
- pushl %edx
- pushl %ecx
- movl arg2, %esi
- subl %eax, %eax
- testl %esi, %esi
- jz .L_fine
- call _get_crc_table
- movl %eax, %edi
- movl arg1, %eax
- #ifndef __686
- subl %ebx, %ebx
- #endif
- movl arg3, %ecx
- notl %eax
- testl %ecx, %ecx
- #ifndef NO_UNROLLED_LOOPS
- jz .L_bail
- # ifndef NO_32_BIT_LOADS
-
- .L_align_loop:
- testl $3, %esi
- jz .L_aligned_now
- Do_CRC_byte
- decl %ecx
- jnz .L_align_loop
- .L_aligned_now:
- # endif
- movl %ecx, SavLen
- shrl $4, %ecx
- jz .L_No_Sixteens
- ALIGNMENT
- .L_Next_Sixteen:
- # ifndef NO_32_BIT_LOADS
- Do_CRC_4lword
- # else
- Do_CRC_byteof(0)
- Do_CRC_byteof(1)
- Do_CRC_byteof(2)
- Do_CRC_byteof(3)
- Do_CRC_byteof(4)
- Do_CRC_byteof(5)
- Do_CRC_byteof(6)
- Do_CRC_byteof(7)
- Do_CRC_byteof(8)
- Do_CRC_byteof(9)
- Do_CRC_byteof(10)
- Do_CRC_byteof(11)
- Do_CRC_byteof(12)
- Do_CRC_byteof(13)
- Do_CRC_byteof(14)
- Do_CRC_byteof(15)
- addl $16,%esi ;
- # endif
- decl %ecx
- jnz .L_Next_Sixteen
- .L_No_Sixteens:
- movl SavLen, %ecx
- andl $15, %ecx
- # ifndef NO_32_BIT_LOADS
- shrl $2,%ecx
- jz .L_No_Fours
- .L_Next_Four:
- Do_CRC_lword
- decl %ecx
- jnz .L_Next_Four
- .L_No_Fours:
- movl SavLen,%ecx
- andl $3,%ecx
- # endif
- #endif
- jz .L_bail
- ALIGNMENT
- .L_loupe:
- Do_CRC_byte
- decl %ecx
- jnz .L_loupe
- .L_bail:
- notl %eax
- .L_fine:
- popl %ecx
- popl %edx
- popl %ebx
- popl %esi
- popl %edi
- _STD_LEAVE
- ret
- #else
- error: this asm version is for 386 only
- #endif
- #endif
|