Import of old SSLeay release: SSLeay 0.9.0b
[openssl.git] / crypto / rc4 / asm / r4-win32.asm
1         ; Don't even think of reading this code
2         ; It was automatically generated by rc4-586.pl
3         ; Which is a perl program used to generate the x86 assember for
4         ; any of elf, a.out, BSDI,Win32, or Solaris
5         ; eric <eay@cryptsoft.com>
6         ; 
7         TITLE   rc4-586.asm
8         .386
9 .model FLAT
10 _TEXT   SEGMENT
11 PUBLIC  _RC4
12
13 _RC4 PROC NEAR
14         ; 
15         push    ebp
16         push    ebx
17         mov     ebp,            DWORD PTR 12[esp]
18         mov     ebx,            DWORD PTR 16[esp]
19         push    esi
20         push    edi
21         mov     ecx,            DWORD PTR [ebp]
22         mov     edx,            DWORD PTR 4[ebp]
23         mov     esi,            DWORD PTR 28[esp]
24         inc     ecx
25         sub     esp,            12
26         add     ebp,            8
27         and     ecx,            255
28         lea     ebx,            DWORD PTR [esi+ebx-8]
29         mov     edi,            DWORD PTR 44[esp]
30         mov     DWORD PTR 8[esp],ebx
31         mov     eax,            DWORD PTR [ecx*4+ebp]
32         cmp     ebx,            esi
33         jl      $L000end
34 L001start:
35         add     esi,            8
36         ; Round 0
37         add     edx,            eax
38         and     edx,            255
39         inc     ecx
40         mov     ebx,            DWORD PTR [edx*4+ebp]
41         mov     DWORD PTR [ecx*4+ebp-4],ebx
42         add     ebx,            eax
43         and     ecx,            255
44         and     ebx,            255
45         mov     DWORD PTR [edx*4+ebp],eax
46         nop
47         mov     ebx,            DWORD PTR [ebx*4+ebp]
48         mov     eax,            DWORD PTR [ecx*4+ebp]
49         mov     BYTE PTR [esp], bl
50         ; Round 1
51         add     edx,            eax
52         and     edx,            255
53         inc     ecx
54         mov     ebx,            DWORD PTR [edx*4+ebp]
55         mov     DWORD PTR [ecx*4+ebp-4],ebx
56         add     ebx,            eax
57         and     ecx,            255
58         and     ebx,            255
59         mov     DWORD PTR [edx*4+ebp],eax
60         nop
61         mov     ebx,            DWORD PTR [ebx*4+ebp]
62         mov     eax,            DWORD PTR [ecx*4+ebp]
63         mov     BYTE PTR 1[esp],bl
64         ; Round 2
65         add     edx,            eax
66         and     edx,            255
67         inc     ecx
68         mov     ebx,            DWORD PTR [edx*4+ebp]
69         mov     DWORD PTR [ecx*4+ebp-4],ebx
70         add     ebx,            eax
71         and     ecx,            255
72         and     ebx,            255
73         mov     DWORD PTR [edx*4+ebp],eax
74         nop
75         mov     ebx,            DWORD PTR [ebx*4+ebp]
76         mov     eax,            DWORD PTR [ecx*4+ebp]
77         mov     BYTE PTR 2[esp],bl
78         ; Round 3
79         add     edx,            eax
80         and     edx,            255
81         inc     ecx
82         mov     ebx,            DWORD PTR [edx*4+ebp]
83         mov     DWORD PTR [ecx*4+ebp-4],ebx
84         add     ebx,            eax
85         and     ecx,            255
86         and     ebx,            255
87         mov     DWORD PTR [edx*4+ebp],eax
88         nop
89         mov     ebx,            DWORD PTR [ebx*4+ebp]
90         mov     eax,            DWORD PTR [ecx*4+ebp]
91         mov     BYTE PTR 3[esp],bl
92         ; Round 4
93         add     edx,            eax
94         and     edx,            255
95         inc     ecx
96         mov     ebx,            DWORD PTR [edx*4+ebp]
97         mov     DWORD PTR [ecx*4+ebp-4],ebx
98         add     ebx,            eax
99         and     ecx,            255
100         and     ebx,            255
101         mov     DWORD PTR [edx*4+ebp],eax
102         nop
103         mov     ebx,            DWORD PTR [ebx*4+ebp]
104         mov     eax,            DWORD PTR [ecx*4+ebp]
105         mov     BYTE PTR 4[esp],bl
106         ; Round 5
107         add     edx,            eax
108         and     edx,            255
109         inc     ecx
110         mov     ebx,            DWORD PTR [edx*4+ebp]
111         mov     DWORD PTR [ecx*4+ebp-4],ebx
112         add     ebx,            eax
113         and     ecx,            255
114         and     ebx,            255
115         mov     DWORD PTR [edx*4+ebp],eax
116         nop
117         mov     ebx,            DWORD PTR [ebx*4+ebp]
118         mov     eax,            DWORD PTR [ecx*4+ebp]
119         mov     BYTE PTR 5[esp],bl
120         ; Round 6
121         add     edx,            eax
122         and     edx,            255
123         inc     ecx
124         mov     ebx,            DWORD PTR [edx*4+ebp]
125         mov     DWORD PTR [ecx*4+ebp-4],ebx
126         add     ebx,            eax
127         and     ecx,            255
128         and     ebx,            255
129         mov     DWORD PTR [edx*4+ebp],eax
130         nop
131         mov     ebx,            DWORD PTR [ebx*4+ebp]
132         mov     eax,            DWORD PTR [ecx*4+ebp]
133         mov     BYTE PTR 6[esp],bl
134         ; Round 7
135         add     edx,            eax
136         and     edx,            255
137         inc     ecx
138         mov     ebx,            DWORD PTR [edx*4+ebp]
139         mov     DWORD PTR [ecx*4+ebp-4],ebx
140         add     ebx,            eax
141         and     ecx,            255
142         and     ebx,            255
143         mov     DWORD PTR [edx*4+ebp],eax
144         nop
145         mov     ebx,            DWORD PTR [ebx*4+ebp]
146         add     edi,            8
147         mov     BYTE PTR 7[esp],bl
148         ; apply the cipher text
149         mov     eax,            DWORD PTR [esp]
150         mov     ebx,            DWORD PTR [esi-8]
151         xor     eax,            ebx
152         mov     ebx,            DWORD PTR [esi-4]
153         mov     DWORD PTR [edi-8],eax
154         mov     eax,            DWORD PTR 4[esp]
155         xor     eax,            ebx
156         mov     ebx,            DWORD PTR 8[esp]
157         mov     DWORD PTR [edi-4],eax
158         mov     eax,            DWORD PTR [ecx*4+ebp]
159         cmp     esi,            ebx
160         jle     L001start
161 $L000end:
162         ; Round 0
163         add     ebx,            8
164         inc     esi
165         cmp     ebx,            esi
166         jl      $L002finished
167         mov     DWORD PTR 8[esp],ebx
168         add     edx,            eax
169         and     edx,            255
170         inc     ecx
171         mov     ebx,            DWORD PTR [edx*4+ebp]
172         mov     DWORD PTR [ecx*4+ebp-4],ebx
173         add     ebx,            eax
174         and     ecx,            255
175         and     ebx,            255
176         mov     DWORD PTR [edx*4+ebp],eax
177         nop
178         mov     ebx,            DWORD PTR [ebx*4+ebp]
179         mov     eax,            DWORD PTR [ecx*4+ebp]
180         mov     bh,             BYTE PTR [esi-1]
181         xor     bl,             bh
182         mov     BYTE PTR [edi], bl
183         ; Round 1
184         mov     ebx,            DWORD PTR 8[esp]
185         cmp     ebx,            esi
186         jle     $L002finished
187         inc     esi
188         add     edx,            eax
189         and     edx,            255
190         inc     ecx
191         mov     ebx,            DWORD PTR [edx*4+ebp]
192         mov     DWORD PTR [ecx*4+ebp-4],ebx
193         add     ebx,            eax
194         and     ecx,            255
195         and     ebx,            255
196         mov     DWORD PTR [edx*4+ebp],eax
197         nop
198         mov     ebx,            DWORD PTR [ebx*4+ebp]
199         mov     eax,            DWORD PTR [ecx*4+ebp]
200         mov     bh,             BYTE PTR [esi-1]
201         xor     bl,             bh
202         mov     BYTE PTR 1[edi],bl
203         ; Round 2
204         mov     ebx,            DWORD PTR 8[esp]
205         cmp     ebx,            esi
206         jle     $L002finished
207         inc     esi
208         add     edx,            eax
209         and     edx,            255
210         inc     ecx
211         mov     ebx,            DWORD PTR [edx*4+ebp]
212         mov     DWORD PTR [ecx*4+ebp-4],ebx
213         add     ebx,            eax
214         and     ecx,            255
215         and     ebx,            255
216         mov     DWORD PTR [edx*4+ebp],eax
217         nop
218         mov     ebx,            DWORD PTR [ebx*4+ebp]
219         mov     eax,            DWORD PTR [ecx*4+ebp]
220         mov     bh,             BYTE PTR [esi-1]
221         xor     bl,             bh
222         mov     BYTE PTR 2[edi],bl
223         ; Round 3
224         mov     ebx,            DWORD PTR 8[esp]
225         cmp     ebx,            esi
226         jle     $L002finished
227         inc     esi
228         add     edx,            eax
229         and     edx,            255
230         inc     ecx
231         mov     ebx,            DWORD PTR [edx*4+ebp]
232         mov     DWORD PTR [ecx*4+ebp-4],ebx
233         add     ebx,            eax
234         and     ecx,            255
235         and     ebx,            255
236         mov     DWORD PTR [edx*4+ebp],eax
237         nop
238         mov     ebx,            DWORD PTR [ebx*4+ebp]
239         mov     eax,            DWORD PTR [ecx*4+ebp]
240         mov     bh,             BYTE PTR [esi-1]
241         xor     bl,             bh
242         mov     BYTE PTR 3[edi],bl
243         ; Round 4
244         mov     ebx,            DWORD PTR 8[esp]
245         cmp     ebx,            esi
246         jle     $L002finished
247         inc     esi
248         add     edx,            eax
249         and     edx,            255
250         inc     ecx
251         mov     ebx,            DWORD PTR [edx*4+ebp]
252         mov     DWORD PTR [ecx*4+ebp-4],ebx
253         add     ebx,            eax
254         and     ecx,            255
255         and     ebx,            255
256         mov     DWORD PTR [edx*4+ebp],eax
257         nop
258         mov     ebx,            DWORD PTR [ebx*4+ebp]
259         mov     eax,            DWORD PTR [ecx*4+ebp]
260         mov     bh,             BYTE PTR [esi-1]
261         xor     bl,             bh
262         mov     BYTE PTR 4[edi],bl
263         ; Round 5
264         mov     ebx,            DWORD PTR 8[esp]
265         cmp     ebx,            esi
266         jle     $L002finished
267         inc     esi
268         add     edx,            eax
269         and     edx,            255
270         inc     ecx
271         mov     ebx,            DWORD PTR [edx*4+ebp]
272         mov     DWORD PTR [ecx*4+ebp-4],ebx
273         add     ebx,            eax
274         and     ecx,            255
275         and     ebx,            255
276         mov     DWORD PTR [edx*4+ebp],eax
277         nop
278         mov     ebx,            DWORD PTR [ebx*4+ebp]
279         mov     eax,            DWORD PTR [ecx*4+ebp]
280         mov     bh,             BYTE PTR [esi-1]
281         xor     bl,             bh
282         mov     BYTE PTR 5[edi],bl
283         ; Round 6
284         mov     ebx,            DWORD PTR 8[esp]
285         cmp     ebx,            esi
286         jle     $L002finished
287         inc     esi
288         add     edx,            eax
289         and     edx,            255
290         inc     ecx
291         mov     ebx,            DWORD PTR [edx*4+ebp]
292         mov     DWORD PTR [ecx*4+ebp-4],ebx
293         add     ebx,            eax
294         and     ecx,            255
295         and     ebx,            255
296         mov     DWORD PTR [edx*4+ebp],eax
297         nop
298         mov     ebx,            DWORD PTR [ebx*4+ebp]
299         mov     bh,             BYTE PTR [esi-1]
300         xor     bl,             bh
301         mov     BYTE PTR 6[edi],bl
302 $L002finished:
303         dec     ecx
304         add     esp,            12
305         mov     DWORD PTR [ebp-4],edx
306         mov     BYTE PTR [ebp-8],cl
307         pop     edi
308         pop     esi
309         pop     ebx
310         pop     ebp
311         ret
312 _RC4 ENDP
313 _TEXT   ENDS
314 END