Import of old SSLeay release: SSLeay 0.9.0b
[openssl.git] / crypto / bn / asm / bn-win32.asm
1         ; Don't even think of reading this code
2         ; It was automatically generated by bn-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   bn-586.asm
8         .386
9 .model FLAT
10 _TEXT   SEGMENT
11 PUBLIC  _bn_mul_add_words
12
13 _bn_mul_add_words PROC NEAR
14         push    ebp
15         push    ebx
16         push    esi
17         push    edi
18         ; 
19         xor     esi,            esi
20         mov     edi,            DWORD PTR 20[esp]
21         mov     ecx,            DWORD PTR 28[esp]
22         mov     ebx,            DWORD PTR 24[esp]
23         and     ecx,            4294967288
24         mov     ebp,            DWORD PTR 32[esp]
25         push    ecx
26         jz      $L000maw_finish
27 L001maw_loop:
28         mov     DWORD PTR [esp],ecx
29         ; Round 0
30         mov     eax,            DWORD PTR [ebx]
31         mul     ebp
32         add     eax,            esi
33         mov     esi,            DWORD PTR [edi]
34         adc     edx,            0
35         add     eax,            esi
36         adc     edx,            0
37         mov     DWORD PTR [edi],eax
38         mov     esi,            edx
39         ; Round 4
40         mov     eax,            DWORD PTR 4[ebx]
41         mul     ebp
42         add     eax,            esi
43         mov     esi,            DWORD PTR 4[edi]
44         adc     edx,            0
45         add     eax,            esi
46         adc     edx,            0
47         mov     DWORD PTR 4[edi],eax
48         mov     esi,            edx
49         ; Round 8
50         mov     eax,            DWORD PTR 8[ebx]
51         mul     ebp
52         add     eax,            esi
53         mov     esi,            DWORD PTR 8[edi]
54         adc     edx,            0
55         add     eax,            esi
56         adc     edx,            0
57         mov     DWORD PTR 8[edi],eax
58         mov     esi,            edx
59         ; Round 12
60         mov     eax,            DWORD PTR 12[ebx]
61         mul     ebp
62         add     eax,            esi
63         mov     esi,            DWORD PTR 12[edi]
64         adc     edx,            0
65         add     eax,            esi
66         adc     edx,            0
67         mov     DWORD PTR 12[edi],eax
68         mov     esi,            edx
69         ; Round 16
70         mov     eax,            DWORD PTR 16[ebx]
71         mul     ebp
72         add     eax,            esi
73         mov     esi,            DWORD PTR 16[edi]
74         adc     edx,            0
75         add     eax,            esi
76         adc     edx,            0
77         mov     DWORD PTR 16[edi],eax
78         mov     esi,            edx
79         ; Round 20
80         mov     eax,            DWORD PTR 20[ebx]
81         mul     ebp
82         add     eax,            esi
83         mov     esi,            DWORD PTR 20[edi]
84         adc     edx,            0
85         add     eax,            esi
86         adc     edx,            0
87         mov     DWORD PTR 20[edi],eax
88         mov     esi,            edx
89         ; Round 24
90         mov     eax,            DWORD PTR 24[ebx]
91         mul     ebp
92         add     eax,            esi
93         mov     esi,            DWORD PTR 24[edi]
94         adc     edx,            0
95         add     eax,            esi
96         adc     edx,            0
97         mov     DWORD PTR 24[edi],eax
98         mov     esi,            edx
99         ; Round 28
100         mov     eax,            DWORD PTR 28[ebx]
101         mul     ebp
102         add     eax,            esi
103         mov     esi,            DWORD PTR 28[edi]
104         adc     edx,            0
105         add     eax,            esi
106         adc     edx,            0
107         mov     DWORD PTR 28[edi],eax
108         mov     esi,            edx
109         ; 
110         mov     ecx,            DWORD PTR [esp]
111         add     ebx,            32
112         add     edi,            32
113         sub     ecx,            8
114         jnz     L001maw_loop
115 $L000maw_finish:
116         mov     ecx,            DWORD PTR 32[esp]
117         and     ecx,            7
118         jnz     $L002maw_finish2
119         jmp     $L003maw_end
120 $L002maw_finish2:
121         ; Tail Round 0
122         mov     eax,            DWORD PTR [ebx]
123         mul     ebp
124         add     eax,            esi
125         mov     esi,            DWORD PTR [edi]
126         adc     edx,            0
127         add     eax,            esi
128         adc     edx,            0
129         dec     ecx
130         mov     DWORD PTR [edi],eax
131         mov     esi,            edx
132         jz      $L003maw_end
133         ; Tail Round 1
134         mov     eax,            DWORD PTR 4[ebx]
135         mul     ebp
136         add     eax,            esi
137         mov     esi,            DWORD PTR 4[edi]
138         adc     edx,            0
139         add     eax,            esi
140         adc     edx,            0
141         dec     ecx
142         mov     DWORD PTR 4[edi],eax
143         mov     esi,            edx
144         jz      $L003maw_end
145         ; Tail Round 2
146         mov     eax,            DWORD PTR 8[ebx]
147         mul     ebp
148         add     eax,            esi
149         mov     esi,            DWORD PTR 8[edi]
150         adc     edx,            0
151         add     eax,            esi
152         adc     edx,            0
153         dec     ecx
154         mov     DWORD PTR 8[edi],eax
155         mov     esi,            edx
156         jz      $L003maw_end
157         ; Tail Round 3
158         mov     eax,            DWORD PTR 12[ebx]
159         mul     ebp
160         add     eax,            esi
161         mov     esi,            DWORD PTR 12[edi]
162         adc     edx,            0
163         add     eax,            esi
164         adc     edx,            0
165         dec     ecx
166         mov     DWORD PTR 12[edi],eax
167         mov     esi,            edx
168         jz      $L003maw_end
169         ; Tail Round 4
170         mov     eax,            DWORD PTR 16[ebx]
171         mul     ebp
172         add     eax,            esi
173         mov     esi,            DWORD PTR 16[edi]
174         adc     edx,            0
175         add     eax,            esi
176         adc     edx,            0
177         dec     ecx
178         mov     DWORD PTR 16[edi],eax
179         mov     esi,            edx
180         jz      $L003maw_end
181         ; Tail Round 5
182         mov     eax,            DWORD PTR 20[ebx]
183         mul     ebp
184         add     eax,            esi
185         mov     esi,            DWORD PTR 20[edi]
186         adc     edx,            0
187         add     eax,            esi
188         adc     edx,            0
189         dec     ecx
190         mov     DWORD PTR 20[edi],eax
191         mov     esi,            edx
192         jz      $L003maw_end
193         ; Tail Round 6
194         mov     eax,            DWORD PTR 24[ebx]
195         mul     ebp
196         add     eax,            esi
197         mov     esi,            DWORD PTR 24[edi]
198         adc     edx,            0
199         add     eax,            esi
200         adc     edx,            0
201         mov     DWORD PTR 24[edi],eax
202         mov     esi,            edx
203 $L003maw_end:
204         mov     eax,            esi
205         pop     ecx
206         pop     edi
207         pop     esi
208         pop     ebx
209         pop     ebp
210         ret
211 _bn_mul_add_words ENDP
212 _TEXT   ENDS
213 _TEXT   SEGMENT
214 PUBLIC  _bn_mul_words
215
216 _bn_mul_words PROC NEAR
217         push    ebp
218         push    ebx
219         push    esi
220         push    edi
221         ; 
222         xor     esi,            esi
223         mov     edi,            DWORD PTR 20[esp]
224         mov     ebx,            DWORD PTR 24[esp]
225         mov     ebp,            DWORD PTR 28[esp]
226         mov     ecx,            DWORD PTR 32[esp]
227         and     ebp,            4294967288
228         jz      $L004mw_finish
229 L005mw_loop:
230         ; Round 0
231         mov     eax,            DWORD PTR [ebx]
232         mul     ecx
233         add     eax,            esi
234         adc     edx,            0
235         mov     DWORD PTR [edi],eax
236         mov     esi,            edx
237         ; Round 4
238         mov     eax,            DWORD PTR 4[ebx]
239         mul     ecx
240         add     eax,            esi
241         adc     edx,            0
242         mov     DWORD PTR 4[edi],eax
243         mov     esi,            edx
244         ; Round 8
245         mov     eax,            DWORD PTR 8[ebx]
246         mul     ecx
247         add     eax,            esi
248         adc     edx,            0
249         mov     DWORD PTR 8[edi],eax
250         mov     esi,            edx
251         ; Round 12
252         mov     eax,            DWORD PTR 12[ebx]
253         mul     ecx
254         add     eax,            esi
255         adc     edx,            0
256         mov     DWORD PTR 12[edi],eax
257         mov     esi,            edx
258         ; Round 16
259         mov     eax,            DWORD PTR 16[ebx]
260         mul     ecx
261         add     eax,            esi
262         adc     edx,            0
263         mov     DWORD PTR 16[edi],eax
264         mov     esi,            edx
265         ; Round 20
266         mov     eax,            DWORD PTR 20[ebx]
267         mul     ecx
268         add     eax,            esi
269         adc     edx,            0
270         mov     DWORD PTR 20[edi],eax
271         mov     esi,            edx
272         ; Round 24
273         mov     eax,            DWORD PTR 24[ebx]
274         mul     ecx
275         add     eax,            esi
276         adc     edx,            0
277         mov     DWORD PTR 24[edi],eax
278         mov     esi,            edx
279         ; Round 28
280         mov     eax,            DWORD PTR 28[ebx]
281         mul     ecx
282         add     eax,            esi
283         adc     edx,            0
284         mov     DWORD PTR 28[edi],eax
285         mov     esi,            edx
286         ; 
287         add     ebx,            32
288         add     edi,            32
289         sub     ebp,            8
290         jz      $L004mw_finish
291         jmp     L005mw_loop
292 $L004mw_finish:
293         mov     ebp,            DWORD PTR 28[esp]
294         and     ebp,            7
295         jnz     $L006mw_finish2
296         jmp     $L007mw_end
297 $L006mw_finish2:
298         ; Tail Round 0
299         mov     eax,            DWORD PTR [ebx]
300         mul     ecx
301         add     eax,            esi
302         adc     edx,            0
303         mov     DWORD PTR [edi],eax
304         mov     esi,            edx
305         dec     ebp
306         jz      $L007mw_end
307         ; Tail Round 1
308         mov     eax,            DWORD PTR 4[ebx]
309         mul     ecx
310         add     eax,            esi
311         adc     edx,            0
312         mov     DWORD PTR 4[edi],eax
313         mov     esi,            edx
314         dec     ebp
315         jz      $L007mw_end
316         ; Tail Round 2
317         mov     eax,            DWORD PTR 8[ebx]
318         mul     ecx
319         add     eax,            esi
320         adc     edx,            0
321         mov     DWORD PTR 8[edi],eax
322         mov     esi,            edx
323         dec     ebp
324         jz      $L007mw_end
325         ; Tail Round 3
326         mov     eax,            DWORD PTR 12[ebx]
327         mul     ecx
328         add     eax,            esi
329         adc     edx,            0
330         mov     DWORD PTR 12[edi],eax
331         mov     esi,            edx
332         dec     ebp
333         jz      $L007mw_end
334         ; Tail Round 4
335         mov     eax,            DWORD PTR 16[ebx]
336         mul     ecx
337         add     eax,            esi
338         adc     edx,            0
339         mov     DWORD PTR 16[edi],eax
340         mov     esi,            edx
341         dec     ebp
342         jz      $L007mw_end
343         ; Tail Round 5
344         mov     eax,            DWORD PTR 20[ebx]
345         mul     ecx
346         add     eax,            esi
347         adc     edx,            0
348         mov     DWORD PTR 20[edi],eax
349         mov     esi,            edx
350         dec     ebp
351         jz      $L007mw_end
352         ; Tail Round 6
353         mov     eax,            DWORD PTR 24[ebx]
354         mul     ecx
355         add     eax,            esi
356         adc     edx,            0
357         mov     DWORD PTR 24[edi],eax
358         mov     esi,            edx
359 $L007mw_end:
360         mov     eax,            esi
361         pop     edi
362         pop     esi
363         pop     ebx
364         pop     ebp
365         ret
366 _bn_mul_words ENDP
367 _TEXT   ENDS
368 _TEXT   SEGMENT
369 PUBLIC  _bn_sqr_words
370
371 _bn_sqr_words PROC NEAR
372         push    ebp
373         push    ebx
374         push    esi
375         push    edi
376         ; 
377         mov     esi,            DWORD PTR 20[esp]
378         mov     edi,            DWORD PTR 24[esp]
379         mov     ebx,            DWORD PTR 28[esp]
380         and     ebx,            4294967288
381         jz      $L008sw_finish
382 L009sw_loop:
383         ; Round 0
384         mov     eax,            DWORD PTR [edi]
385         mul     eax
386         mov     DWORD PTR [esi],eax
387         mov     DWORD PTR 4[esi],edx
388         ; Round 4
389         mov     eax,            DWORD PTR 4[edi]
390         mul     eax
391         mov     DWORD PTR 8[esi],eax
392         mov     DWORD PTR 12[esi],edx
393         ; Round 8
394         mov     eax,            DWORD PTR 8[edi]
395         mul     eax
396         mov     DWORD PTR 16[esi],eax
397         mov     DWORD PTR 20[esi],edx
398         ; Round 12
399         mov     eax,            DWORD PTR 12[edi]
400         mul     eax
401         mov     DWORD PTR 24[esi],eax
402         mov     DWORD PTR 28[esi],edx
403         ; Round 16
404         mov     eax,            DWORD PTR 16[edi]
405         mul     eax
406         mov     DWORD PTR 32[esi],eax
407         mov     DWORD PTR 36[esi],edx
408         ; Round 20
409         mov     eax,            DWORD PTR 20[edi]
410         mul     eax
411         mov     DWORD PTR 40[esi],eax
412         mov     DWORD PTR 44[esi],edx
413         ; Round 24
414         mov     eax,            DWORD PTR 24[edi]
415         mul     eax
416         mov     DWORD PTR 48[esi],eax
417         mov     DWORD PTR 52[esi],edx
418         ; Round 28
419         mov     eax,            DWORD PTR 28[edi]
420         mul     eax
421         mov     DWORD PTR 56[esi],eax
422         mov     DWORD PTR 60[esi],edx
423         ; 
424         add     edi,            32
425         add     esi,            64
426         sub     ebx,            8
427         jnz     L009sw_loop
428 $L008sw_finish:
429         mov     ebx,            DWORD PTR 28[esp]
430         and     ebx,            7
431         jz      $L010sw_end
432         ; Tail Round 0
433         mov     eax,            DWORD PTR [edi]
434         mul     eax
435         mov     DWORD PTR [esi],eax
436         dec     ebx
437         mov     DWORD PTR 4[esi],edx
438         jz      $L010sw_end
439         ; Tail Round 1
440         mov     eax,            DWORD PTR 4[edi]
441         mul     eax
442         mov     DWORD PTR 8[esi],eax
443         dec     ebx
444         mov     DWORD PTR 12[esi],edx
445         jz      $L010sw_end
446         ; Tail Round 2
447         mov     eax,            DWORD PTR 8[edi]
448         mul     eax
449         mov     DWORD PTR 16[esi],eax
450         dec     ebx
451         mov     DWORD PTR 20[esi],edx
452         jz      $L010sw_end
453         ; Tail Round 3
454         mov     eax,            DWORD PTR 12[edi]
455         mul     eax
456         mov     DWORD PTR 24[esi],eax
457         dec     ebx
458         mov     DWORD PTR 28[esi],edx
459         jz      $L010sw_end
460         ; Tail Round 4
461         mov     eax,            DWORD PTR 16[edi]
462         mul     eax
463         mov     DWORD PTR 32[esi],eax
464         dec     ebx
465         mov     DWORD PTR 36[esi],edx
466         jz      $L010sw_end
467         ; Tail Round 5
468         mov     eax,            DWORD PTR 20[edi]
469         mul     eax
470         mov     DWORD PTR 40[esi],eax
471         dec     ebx
472         mov     DWORD PTR 44[esi],edx
473         jz      $L010sw_end
474         ; Tail Round 6
475         mov     eax,            DWORD PTR 24[edi]
476         mul     eax
477         mov     DWORD PTR 48[esi],eax
478         mov     DWORD PTR 52[esi],edx
479 $L010sw_end:
480         pop     edi
481         pop     esi
482         pop     ebx
483         pop     ebp
484         ret
485 _bn_sqr_words ENDP
486 _TEXT   ENDS
487 _TEXT   SEGMENT
488 PUBLIC  _bn_div64
489
490 _bn_div64 PROC NEAR
491         push    ebp
492         push    ebx
493         push    esi
494         push    edi
495         mov     edx,            DWORD PTR 20[esp]
496         mov     eax,            DWORD PTR 24[esp]
497         mov     ebx,            DWORD PTR 28[esp]
498         div     ebx
499         pop     edi
500         pop     esi
501         pop     ebx
502         pop     ebp
503         ret
504 _bn_div64 ENDP
505 _TEXT   ENDS
506 _TEXT   SEGMENT
507 PUBLIC  _bn_add_words
508
509 _bn_add_words PROC NEAR
510         push    ebp
511         push    ebx
512         push    esi
513         push    edi
514         ; 
515         mov     ebx,            DWORD PTR 20[esp]
516         mov     esi,            DWORD PTR 24[esp]
517         mov     edi,            DWORD PTR 28[esp]
518         mov     ebp,            DWORD PTR 32[esp]
519         xor     eax,            eax
520         and     ebp,            4294967288
521         jz      $L011aw_finish
522 L012aw_loop:
523         ; Round 0
524         mov     ecx,            DWORD PTR [esi]
525         mov     edx,            DWORD PTR [edi]
526         add     ecx,            eax
527         mov     eax,            0
528         adc     eax,            eax
529         add     ecx,            edx
530         adc     eax,            0
531         mov     DWORD PTR [ebx],ecx
532         ; Round 1
533         mov     ecx,            DWORD PTR 4[esi]
534         mov     edx,            DWORD PTR 4[edi]
535         add     ecx,            eax
536         mov     eax,            0
537         adc     eax,            eax
538         add     ecx,            edx
539         adc     eax,            0
540         mov     DWORD PTR 4[ebx],ecx
541         ; Round 2
542         mov     ecx,            DWORD PTR 8[esi]
543         mov     edx,            DWORD PTR 8[edi]
544         add     ecx,            eax
545         mov     eax,            0
546         adc     eax,            eax
547         add     ecx,            edx
548         adc     eax,            0
549         mov     DWORD PTR 8[ebx],ecx
550         ; Round 3
551         mov     ecx,            DWORD PTR 12[esi]
552         mov     edx,            DWORD PTR 12[edi]
553         add     ecx,            eax
554         mov     eax,            0
555         adc     eax,            eax
556         add     ecx,            edx
557         adc     eax,            0
558         mov     DWORD PTR 12[ebx],ecx
559         ; Round 4
560         mov     ecx,            DWORD PTR 16[esi]
561         mov     edx,            DWORD PTR 16[edi]
562         add     ecx,            eax
563         mov     eax,            0
564         adc     eax,            eax
565         add     ecx,            edx
566         adc     eax,            0
567         mov     DWORD PTR 16[ebx],ecx
568         ; Round 5
569         mov     ecx,            DWORD PTR 20[esi]
570         mov     edx,            DWORD PTR 20[edi]
571         add     ecx,            eax
572         mov     eax,            0
573         adc     eax,            eax
574         add     ecx,            edx
575         adc     eax,            0
576         mov     DWORD PTR 20[ebx],ecx
577         ; Round 6
578         mov     ecx,            DWORD PTR 24[esi]
579         mov     edx,            DWORD PTR 24[edi]
580         add     ecx,            eax
581         mov     eax,            0
582         adc     eax,            eax
583         add     ecx,            edx
584         adc     eax,            0
585         mov     DWORD PTR 24[ebx],ecx
586         ; Round 7
587         mov     ecx,            DWORD PTR 28[esi]
588         mov     edx,            DWORD PTR 28[edi]
589         add     ecx,            eax
590         mov     eax,            0
591         adc     eax,            eax
592         add     ecx,            edx
593         adc     eax,            0
594         mov     DWORD PTR 28[ebx],ecx
595         ; 
596         add     esi,            32
597         add     edi,            32
598         add     ebx,            32
599         sub     ebp,            8
600         jnz     L012aw_loop
601 $L011aw_finish:
602         mov     ebp,            DWORD PTR 32[esp]
603         and     ebp,            7
604         jz      $L013aw_end
605         ; Tail Round 0
606         mov     ecx,            DWORD PTR [esi]
607         mov     edx,            DWORD PTR [edi]
608         add     ecx,            eax
609         mov     eax,            0
610         adc     eax,            eax
611         add     ecx,            edx
612         adc     eax,            0
613         dec     ebp
614         mov     DWORD PTR [ebx],ecx
615         jz      $L013aw_end
616         ; Tail Round 1
617         mov     ecx,            DWORD PTR 4[esi]
618         mov     edx,            DWORD PTR 4[edi]
619         add     ecx,            eax
620         mov     eax,            0
621         adc     eax,            eax
622         add     ecx,            edx
623         adc     eax,            0
624         dec     ebp
625         mov     DWORD PTR 4[ebx],ecx
626         jz      $L013aw_end
627         ; Tail Round 2
628         mov     ecx,            DWORD PTR 8[esi]
629         mov     edx,            DWORD PTR 8[edi]
630         add     ecx,            eax
631         mov     eax,            0
632         adc     eax,            eax
633         add     ecx,            edx
634         adc     eax,            0
635         dec     ebp
636         mov     DWORD PTR 8[ebx],ecx
637         jz      $L013aw_end
638         ; Tail Round 3
639         mov     ecx,            DWORD PTR 12[esi]
640         mov     edx,            DWORD PTR 12[edi]
641         add     ecx,            eax
642         mov     eax,            0
643         adc     eax,            eax
644         add     ecx,            edx
645         adc     eax,            0
646         dec     ebp
647         mov     DWORD PTR 12[ebx],ecx
648         jz      $L013aw_end
649         ; Tail Round 4
650         mov     ecx,            DWORD PTR 16[esi]
651         mov     edx,            DWORD PTR 16[edi]
652         add     ecx,            eax
653         mov     eax,            0
654         adc     eax,            eax
655         add     ecx,            edx
656         adc     eax,            0
657         dec     ebp
658         mov     DWORD PTR 16[ebx],ecx
659         jz      $L013aw_end
660         ; Tail Round 5
661         mov     ecx,            DWORD PTR 20[esi]
662         mov     edx,            DWORD PTR 20[edi]
663         add     ecx,            eax
664         mov     eax,            0
665         adc     eax,            eax
666         add     ecx,            edx
667         adc     eax,            0
668         dec     ebp
669         mov     DWORD PTR 20[ebx],ecx
670         jz      $L013aw_end
671         ; Tail Round 6
672         mov     ecx,            DWORD PTR 24[esi]
673         mov     edx,            DWORD PTR 24[edi]
674         add     ecx,            eax
675         mov     eax,            0
676         adc     eax,            eax
677         add     ecx,            edx
678         adc     eax,            0
679         mov     DWORD PTR 24[ebx],ecx
680 $L013aw_end:
681         mov     eax,            eax
682         pop     edi
683         pop     esi
684         pop     ebx
685         pop     ebp
686         ret
687 _bn_add_words ENDP
688 _TEXT   ENDS
689 END