crc_lcc.asm 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. ;===========================================================================
  2. ; Copyright (c) 1990-2006 Info-ZIP. All rights reserved.
  3. ;
  4. ; See the accompanying file LICENSE, version 2000-Apr-09 or later
  5. ; (the contents of which are also included in zip.h) for terms of use.
  6. ; If, for some reason, all these files are missing, the Info-ZIP license
  7. ; also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
  8. ;===========================================================================
  9. ; crc_lcc.asm, optimized CRC calculation function for Zip and UnZip,
  10. ; created by Paul Kienitz and Christian Spieler. Last revised 02 Jan 2006.
  11. ;
  12. ; The code in this file has been copied verbatim from crc_i386.{asm|S};
  13. ; only the assembler syntax and metacommands have been adapted to
  14. ; the habits of the free LCC-Win32 C compiler package.
  15. ; This version of the code uses the "optimized for i686" variant of
  16. ; crc_i386.{asm|S}.
  17. ; IMPORTANT NOTE to the Info-ZIP editors:
  18. ; The TAB characters in this source file are required by the parser of
  19. ; the LCC-Win32 assembler program and MUST NOT be removed!!
  20. ;
  21. ; For more information (and a revision log), look into the original
  22. ; source files.
  23. ;
  24. .text
  25. .file "crc32.c"
  26. .text
  27. .type _crc32,function
  28. _crc32:
  29. pushl %ebp
  30. movl %esp,%ebp
  31. pushl %ecx
  32. pushl %ebx
  33. pushl %esi
  34. pushl %edi
  35. .line 34
  36. .line 37
  37. movl 12(%ebp),%esi
  38. subl %eax,%eax
  39. testl %esi,%esi
  40. jz _$3
  41. .line 39
  42. call _get_crc_table
  43. movl %eax,%edi
  44. .line 41
  45. movl 8(%ebp),%eax
  46. movl 16(%ebp),%ecx
  47. notl %eax
  48. testl %ecx,%ecx
  49. jz _$4
  50. _$5:
  51. testl $3,%esi
  52. jz _$6
  53. xorb (%esi),%al
  54. incl %esi
  55. movzbl %al,%ebx
  56. shrl $8,%eax
  57. xorl (%edi,%ebx,4),%eax
  58. decl %ecx
  59. jnz _$5
  60. _$6:
  61. movl %ecx,%edx
  62. shrl $4,%ecx
  63. jz _$8
  64. _$7:
  65. xorl (%esi),%eax
  66. movzbl %al,%ebx
  67. shrl $8,%eax
  68. xorl (%edi,%ebx,4),%eax
  69. movzbl %al,%ebx
  70. shrl $8,%eax
  71. xorl (%edi,%ebx,4),%eax
  72. movzbl %al,%ebx
  73. shrl $8,%eax
  74. xorl (%edi,%ebx,4),%eax
  75. movzbl %al,%ebx
  76. shrl $8,%eax
  77. xorl (%edi,%ebx,4),%eax
  78. xorl 4(%esi),%eax
  79. movzbl %al,%ebx
  80. shrl $8,%eax
  81. xorl (%edi,%ebx,4),%eax
  82. movzbl %al,%ebx
  83. shrl $8,%eax
  84. xorl (%edi,%ebx,4),%eax
  85. movzbl %al,%ebx
  86. shrl $8,%eax
  87. xorl (%edi,%ebx,4),%eax
  88. movzbl %al,%ebx
  89. shrl $8,%eax
  90. xorl (%edi,%ebx,4),%eax
  91. xorl 8(%esi),%eax
  92. movzbl %al,%ebx
  93. shrl $8,%eax
  94. xorl (%edi,%ebx,4),%eax
  95. movzbl %al,%ebx
  96. shrl $8,%eax
  97. xorl (%edi,%ebx,4),%eax
  98. movzbl %al,%ebx
  99. shrl $8,%eax
  100. xorl (%edi,%ebx,4),%eax
  101. movzbl %al,%ebx
  102. shrl $8,%eax
  103. xorl (%edi,%ebx,4),%eax
  104. xorl 12(%esi),%eax
  105. movzbl %al,%ebx
  106. shrl $8,%eax
  107. xorl (%edi,%ebx,4),%eax
  108. movzbl %al,%ebx
  109. shrl $8,%eax
  110. xorl (%edi,%ebx,4),%eax
  111. addl $16,%esi
  112. movzbl %al,%ebx
  113. shrl $8,%eax
  114. xorl (%edi,%ebx,4),%eax
  115. movzbl %al,%ebx
  116. shrl $8,%eax
  117. xorl (%edi,%ebx,4),%eax
  118. decl %ecx
  119. jnz _$7
  120. _$8:
  121. movl %edx,%ecx
  122. andl $0x0f,%ecx
  123. shrl $2,%ecx
  124. jz _$10
  125. _$9:
  126. xorl (%esi),%eax
  127. movzbl %al,%ebx
  128. shrl $8,%eax
  129. xorl (%edi,%ebx,4),%eax
  130. movzbl %al,%ebx
  131. shrl $8,%eax
  132. xorl (%edi,%ebx,4),%eax
  133. addl $4,%esi
  134. movzbl %al,%ebx
  135. shrl $8,%eax
  136. xorl (%edi,%ebx,4),%eax
  137. movzbl %al,%ebx
  138. shrl $8,%eax
  139. xorl (%edi,%ebx,4),%eax
  140. decl %ecx
  141. jnz _$9
  142. _$10:
  143. movl %edx,%ecx
  144. andl $0x03,%ecx
  145. jz _$4
  146. _$11:
  147. xorb (%esi),%al
  148. incl %esi
  149. movzbl %al,%ebx
  150. shrl $8,%eax
  151. xorl (%edi,%ebx,4),%eax
  152. decl %ecx
  153. jnz _$11
  154. _$4:
  155. xorl $0xffffffff,%eax
  156. _$3:
  157. .line 52
  158. popl %edi
  159. popl %esi
  160. popl %ebx
  161. leave
  162. ret
  163. _$34:
  164. .size _crc32,_$34-_crc32
  165. .globl _crc32
  166. .extern _get_crc_table