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