Remove filename argument to x86 asm_init.
[openssl.git] / crypto / ripemd / asm / rmd-586.pl
1 #! /usr/bin/env perl
2 # Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3 #
4 # Licensed under the OpenSSL license (the "License").  You may not use
5 # this file except in compliance with the License.  You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
8
9
10 # Normal is the
11 # ripemd160_block_asm_data_order(RIPEMD160_CTX *c, ULONG *X,int blocks);
12
13 $normal=0;
14
15 $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
16 push(@INC,"${dir}","${dir}../../perlasm");
17 require "x86asm.pl";
18
19 $output=pop;
20 open STDOUT,">$output";
21
22 &asm_init($ARGV[0]);
23
24 $A="ecx";
25 $B="esi";
26 $C="edi";
27 $D="ebx";
28 $E="ebp";
29 $tmp1="eax";
30 $tmp2="edx";
31
32 $KL1=0x5A827999;
33 $KL2=0x6ED9EBA1;
34 $KL3=0x8F1BBCDC;
35 $KL4=0xA953FD4E;
36 $KR0=0x50A28BE6;
37 $KR1=0x5C4DD124;
38 $KR2=0x6D703EF3;
39 $KR3=0x7A6D76E9;
40
41
42 @wl=(    0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,
43          7, 4,13, 1,10, 6,15, 3,12, 0, 9, 5, 2,14,11, 8,
44          3,10,14, 4, 9,15, 8, 1, 2, 7, 0, 6,13,11, 5,12,
45          1, 9,11,10, 0, 8,12, 4,13, 3, 7,15,14, 5, 6, 2,
46          4, 0, 5, 9, 7,12, 2,10,14, 1, 3, 8,11, 6,15,13,
47          );
48
49 @wr=(    5,14, 7, 0, 9, 2,11, 4,13, 6,15, 8, 1,10, 3,12,
50          6,11, 3, 7, 0,13, 5,10,14,15, 8,12, 4, 9, 1, 2,
51         15, 5, 1, 3, 7,14, 6, 9,11, 8,12, 2,10, 0, 4,13,
52          8, 6, 4, 1, 3,11,15, 0, 5,12, 2,13, 9, 7,10,14,
53         12,15,10, 4, 1, 5, 8, 7, 6, 2,13,14, 0, 3, 9,11,
54         );
55
56 @sl=(   11,14,15,12, 5, 8, 7, 9,11,13,14,15, 6, 7, 9, 8,
57          7, 6, 8,13,11, 9, 7,15, 7,12,15, 9,11, 7,13,12,
58         11,13, 6, 7,14, 9,13,15,14, 8,13, 6, 5,12, 7, 5,
59         11,12,14,15,14,15, 9, 8, 9,14, 5, 6, 8, 6, 5,12,
60          9,15, 5,11, 6, 8,13,12, 5,12,13,14,11, 8, 5, 6,
61          );
62
63 @sr=(    8, 9, 9,11,13,15,15, 5, 7, 7, 8,11,14,14,12, 6,
64          9,13,15, 7,12, 8, 9,11, 7, 7,12, 7, 6,15,13,11,
65          9, 7,15,11, 8, 6, 6,14,12,13, 5,14,13,13, 7, 5,
66         15, 5, 8,11,14,14, 6,14, 6, 9,12, 9,12, 5,15, 8,
67          8, 5,12, 9,12, 5,14, 6, 8,13, 6, 5,15,13,11,11,
68         );
69
70 &ripemd160_block("ripemd160_block_asm_data_order");
71 &asm_finish();
72
73 close STDOUT;
74
75 sub Xv
76         {
77         local($n)=@_;
78         return(&swtmp($n));
79         # tmp on stack
80         }
81
82 sub Np
83         {
84         local($p)=@_;
85         local(%n)=($A,$E,$B,$A,$C,$B,$D,$C,$E,$D);
86         return($n{$p});
87         }
88
89 sub RIP1
90         {
91         local($a,$b,$c,$d,$e,$pos,$s,$o,$pos2)=@_;
92
93         &comment($p++);
94         if ($p & 1)
95                 {
96          #&mov($tmp1,   $c) if $o == -1;
97         &xor($tmp1,     $d) if $o == -1;
98          &mov($tmp2,    &Xv($pos));
99         &xor($tmp1,     $b);
100          &add($a,       $tmp2);
101         &rotl($c,       10);
102         &add($a,        $tmp1);
103          &mov($tmp1,    &Np($c));       # NEXT
104          # XXX
105         &rotl($a,       $s);
106         &add($a,        $e);
107                 }
108         else
109                 {
110          &xor($tmp1,    $d);
111         &mov($tmp2,     &Xv($pos));
112          &xor($tmp1,    $b);
113         &add($a,        $tmp1);
114          &mov($tmp1,    &Np($c)) if $o <= 0;
115          &mov($tmp1,    -1) if $o == 1;
116          # XXX if $o == 2;
117         &rotl($c,       10);
118         &add($a,        $tmp2);
119          &xor($tmp1,    &Np($d)) if $o <= 0;
120          &mov($tmp2,    &Xv($pos2)) if $o == 1;
121          &mov($tmp2,    &wparam(0)) if $o == 2;
122         &rotl($a,       $s);
123         &add($a,        $e);
124                 }
125         }
126
127 sub RIP2
128         {
129         local($a,$b,$c,$d,$e,$pos,$pos2,$s,$K,$o)=@_;
130
131 # XXXXXX
132         &comment($p++);
133         if ($p & 1)
134                 {
135 #        &mov($tmp2,    &Xv($pos)) if $o < -1;
136 #       &mov($tmp1,     -1) if $o < -1;
137
138          &add($a,       $tmp2);
139         &mov($tmp2,     $c);
140          &sub($tmp1,    $b);
141         &and($tmp2,     $b);
142          &and($tmp1,    $d);
143         &or($tmp2,      $tmp1);
144          &mov($tmp1,    &Xv($pos2)) if $o <= 0; # XXXXXXXXXXXXXX
145          # XXX
146         &rotl($c,       10);
147         &lea($a,        &DWP($K,$a,$tmp2,1));
148          &mov($tmp2,    -1) if $o <= 0;
149          # XXX
150         &rotl($a,       $s);
151         &add($a,        $e);
152                 }
153         else
154                 {
155          # XXX
156          &add($a,       $tmp1);
157         &mov($tmp1,     $c);
158          &sub($tmp2,    $b);
159         &and($tmp1,     $b);
160          &and($tmp2,    $d);
161         if ($o != 2)
162                 {
163         &or($tmp1,      $tmp2);
164          &mov($tmp2,    &Xv($pos2)) if $o <= 0;
165          &mov($tmp2,    -1) if $o == 1;
166         &rotl($c,       10);
167         &lea($a,        &DWP($K,$a,$tmp1,1));
168          &mov($tmp1,    -1) if $o <= 0;
169          &sub($tmp2,    &Np($c)) if $o == 1;
170                 } else {
171         &or($tmp2,      $tmp1);
172          &mov($tmp1,    &Np($c));
173         &rotl($c,       10);
174         &lea($a,        &DWP($K,$a,$tmp2,1));
175          &xor($tmp1,    &Np($d));
176                 }
177         &rotl($a,       $s);
178         &add($a,        $e);
179                 }
180         }
181
182 sub RIP3
183         {
184         local($a,$b,$c,$d,$e,$pos,$s,$K,$o,$pos2)=@_;
185
186         &comment($p++);
187         if ($p & 1)
188                 {
189 #        &mov($tmp2,    -1) if $o < -1;
190 #       &sub($tmp2,     $c) if $o < -1;
191          &mov($tmp1,    &Xv($pos));
192         &or($tmp2,      $b);
193          &add($a,       $tmp1);
194         &xor($tmp2,     $d);
195          &mov($tmp1,    -1) if $o <= 0;         # NEXT
196          # XXX
197         &rotl($c,       10);
198         &lea($a,        &DWP($K,$a,$tmp2,1));
199          &sub($tmp1,    &Np($c)) if $o <= 0;    # NEXT
200          # XXX
201         &rotl($a,       $s);
202         &add($a,        $e);
203                 }
204         else
205                 {
206          &mov($tmp2,    &Xv($pos));
207         &or($tmp1,      $b);
208          &add($a,       $tmp2);
209         &xor($tmp1,     $d);
210          &mov($tmp2,    -1) if $o <= 0;         # NEXT
211          &mov($tmp2,    -1) if $o == 1;
212          &mov($tmp2,    &Xv($pos2)) if $o == 2;
213         &rotl($c,       10);
214         &lea($a,        &DWP($K,$a,$tmp1,1));
215          &sub($tmp2,    &Np($c)) if $o <= 0;    # NEXT
216          &mov($tmp1,    &Np($d)) if $o == 1;
217          &mov($tmp1,    -1) if $o == 2;
218         &rotl($a,       $s);
219         &add($a,        $e);
220                 }
221         }
222
223 sub RIP4
224         {
225         local($a,$b,$c,$d,$e,$pos,$s,$K,$o)=@_;
226
227         &comment($p++);
228         if ($p & 1)
229                 {
230 #        &mov($tmp2,    -1) if $o == -2;
231 #       &mov($tmp1,     $d) if $o == -2;
232          &sub($tmp2,    $d);
233         &and($tmp1,     $b);
234          &and($tmp2,    $c);
235         &or($tmp2,      $tmp1);
236          &mov($tmp1,    &Xv($pos));
237         &rotl($c,       10);
238         &lea($a,        &DWP($K,$a,$tmp2));
239          &mov($tmp2,    -1) unless $o > 0;      # NEXT
240          # XXX
241         &add($a,        $tmp1);
242          &mov($tmp1,    &Np($d)) unless $o > 0; # NEXT
243          # XXX
244         &rotl($a,       $s);
245         &add($a,        $e);
246                 }
247         else
248                 {
249          &sub($tmp2,    $d);
250         &and($tmp1,     $b);
251          &and($tmp2,    $c);
252         &or($tmp2,      $tmp1);
253          &mov($tmp1,    &Xv($pos));
254         &rotl($c,       10);
255         &lea($a,        &DWP($K,$a,$tmp2));
256          &mov($tmp2,    -1) if $o == 0; # NEXT
257          &mov($tmp2,    -1) if $o == 1;
258          &mov($tmp2,    -1) if $o == 2;
259          # XXX
260         &add($a,        $tmp1);
261          &mov($tmp1,    &Np($d)) if $o == 0;    # NEXT
262          &sub($tmp2,    &Np($d)) if $o == 1;
263          &sub($tmp2,    &Np($c)) if $o == 2;
264          # XXX
265         &rotl($a,       $s);
266         &add($a,        $e);
267                 }
268         }
269
270 sub RIP5
271         {
272         local($a,$b,$c,$d,$e,$pos,$s,$K,$o)=@_;
273
274         &comment($p++);
275         if ($p & 1)
276                 {
277          &mov($tmp2,    -1) if $o == -2;
278         &sub($tmp2,     $d) if $o == -2;
279          &mov($tmp1,    &Xv($pos));
280         &or($tmp2,      $c);
281          &add($a,       $tmp1);
282         &xor($tmp2,     $b);
283          &mov($tmp1,    -1) if $o <= 0;
284          # XXX
285         &rotl($c,       10);
286         &lea($a,        &DWP($K,$a,$tmp2,1));
287          &sub($tmp1,    &Np($d)) if $o <= 0;
288          # XXX
289         &rotl($a,       $s);
290         &add($a,        $e);
291                 }
292         else
293                 {
294          &mov($tmp2,    &Xv($pos));
295         &or($tmp1,      $c);
296          &add($a,       $tmp2);
297         &xor($tmp1,     $b);
298          &mov($tmp2,    -1) if $o <= 0;
299          &mov($tmp2,    &wparam(0)) if $o == 1; # Middle code
300          &mov($tmp2,    -1) if $o == 2;
301         &rotl($c,       10);
302         &lea($a,        &DWP($K,$a,$tmp1,1));
303          &sub($tmp2,    &Np($d)) if $o <= 0;
304          &mov(&swtmp(16),       $A) if $o == 1;
305          &mov($tmp1,    &Np($d)) if $o == 2;
306         &rotl($a,       $s);
307         &add($a,        $e);
308                 }
309         }
310
311 sub ripemd160_block
312         {
313         local($name)=@_;
314
315         &function_begin_B($name,"",3);
316
317         # parameter 1 is the RIPEMD160_CTX structure.
318         # A     0
319         # B     4
320         # C     8
321         # D     12
322         # E     16
323
324         &mov($tmp2,     &wparam(0));
325          &mov($tmp1,    &wparam(1));
326         &push("esi");
327          &mov($A,       &DWP( 0,$tmp2,"",0));
328         &push("edi");
329          &mov($B,       &DWP( 4,$tmp2,"",0));
330         &push("ebp");
331          &mov($C,       &DWP( 8,$tmp2,"",0));
332         &push("ebx");
333          &stack_push(16+5+6);
334                           # Special comment about the figure of 6.
335                           # Idea is to pad the current frame so
336                           # that the top of the stack gets fairly
337                           # aligned. Well, as you realize it would
338                           # always depend on how the frame below is
339                           # aligned. The good news are that gcc-2.95
340                           # and later does keep first argument at
341                           # least double-wise aligned.
342                           #                     <appro@fy.chalmers.se>
343
344         &set_label("start") unless $normal;
345         &comment("");
346
347         # &mov($tmp1,   &wparam(1)); # Done at end of loop
348         # &mov($tmp2,   &wparam(0)); # Done at end of loop
349
350         for ($z=0; $z<16; $z+=2)
351                 {
352                 &mov($D,                &DWP( $z*4,$tmp1,"",0));
353                  &mov($E,               &DWP( ($z+1)*4,$tmp1,"",0));
354                 &mov(&swtmp($z),        $D);
355                  &mov(&swtmp($z+1),     $E);
356                 }
357         &mov($tmp1,     $C);
358          &mov($D,       &DWP(12,$tmp2,"",0));
359         &mov($E,        &DWP(16,$tmp2,"",0));
360
361         &RIP1($A,$B,$C,$D,$E,$wl[ 0],$sl[ 0],-1);
362         &RIP1($E,$A,$B,$C,$D,$wl[ 1],$sl[ 1],0);
363         &RIP1($D,$E,$A,$B,$C,$wl[ 2],$sl[ 2],0);
364         &RIP1($C,$D,$E,$A,$B,$wl[ 3],$sl[ 3],0);
365         &RIP1($B,$C,$D,$E,$A,$wl[ 4],$sl[ 4],0);
366         &RIP1($A,$B,$C,$D,$E,$wl[ 5],$sl[ 5],0);
367         &RIP1($E,$A,$B,$C,$D,$wl[ 6],$sl[ 6],0);
368         &RIP1($D,$E,$A,$B,$C,$wl[ 7],$sl[ 7],0);
369         &RIP1($C,$D,$E,$A,$B,$wl[ 8],$sl[ 8],0);
370         &RIP1($B,$C,$D,$E,$A,$wl[ 9],$sl[ 9],0);
371         &RIP1($A,$B,$C,$D,$E,$wl[10],$sl[10],0);
372         &RIP1($E,$A,$B,$C,$D,$wl[11],$sl[11],0);
373         &RIP1($D,$E,$A,$B,$C,$wl[12],$sl[12],0);
374         &RIP1($C,$D,$E,$A,$B,$wl[13],$sl[13],0);
375         &RIP1($B,$C,$D,$E,$A,$wl[14],$sl[14],0);
376         &RIP1($A,$B,$C,$D,$E,$wl[15],$sl[15],1,$wl[16]);
377
378         &RIP2($E,$A,$B,$C,$D,$wl[16],$wl[17],$sl[16],$KL1,-1);
379         &RIP2($D,$E,$A,$B,$C,$wl[17],$wl[18],$sl[17],$KL1,0);
380         &RIP2($C,$D,$E,$A,$B,$wl[18],$wl[19],$sl[18],$KL1,0);
381         &RIP2($B,$C,$D,$E,$A,$wl[19],$wl[20],$sl[19],$KL1,0);
382         &RIP2($A,$B,$C,$D,$E,$wl[20],$wl[21],$sl[20],$KL1,0);
383         &RIP2($E,$A,$B,$C,$D,$wl[21],$wl[22],$sl[21],$KL1,0);
384         &RIP2($D,$E,$A,$B,$C,$wl[22],$wl[23],$sl[22],$KL1,0);
385         &RIP2($C,$D,$E,$A,$B,$wl[23],$wl[24],$sl[23],$KL1,0);
386         &RIP2($B,$C,$D,$E,$A,$wl[24],$wl[25],$sl[24],$KL1,0);
387         &RIP2($A,$B,$C,$D,$E,$wl[25],$wl[26],$sl[25],$KL1,0);
388         &RIP2($E,$A,$B,$C,$D,$wl[26],$wl[27],$sl[26],$KL1,0);
389         &RIP2($D,$E,$A,$B,$C,$wl[27],$wl[28],$sl[27],$KL1,0);
390         &RIP2($C,$D,$E,$A,$B,$wl[28],$wl[29],$sl[28],$KL1,0);
391         &RIP2($B,$C,$D,$E,$A,$wl[29],$wl[30],$sl[29],$KL1,0);
392         &RIP2($A,$B,$C,$D,$E,$wl[30],$wl[31],$sl[30],$KL1,0);
393         &RIP2($E,$A,$B,$C,$D,$wl[31],$wl[32],$sl[31],$KL1,1);
394
395         &RIP3($D,$E,$A,$B,$C,$wl[32],$sl[32],$KL2,-1);
396         &RIP3($C,$D,$E,$A,$B,$wl[33],$sl[33],$KL2,0);
397         &RIP3($B,$C,$D,$E,$A,$wl[34],$sl[34],$KL2,0);
398         &RIP3($A,$B,$C,$D,$E,$wl[35],$sl[35],$KL2,0);
399         &RIP3($E,$A,$B,$C,$D,$wl[36],$sl[36],$KL2,0);
400         &RIP3($D,$E,$A,$B,$C,$wl[37],$sl[37],$KL2,0);
401         &RIP3($C,$D,$E,$A,$B,$wl[38],$sl[38],$KL2,0);
402         &RIP3($B,$C,$D,$E,$A,$wl[39],$sl[39],$KL2,0);
403         &RIP3($A,$B,$C,$D,$E,$wl[40],$sl[40],$KL2,0);
404         &RIP3($E,$A,$B,$C,$D,$wl[41],$sl[41],$KL2,0);
405         &RIP3($D,$E,$A,$B,$C,$wl[42],$sl[42],$KL2,0);
406         &RIP3($C,$D,$E,$A,$B,$wl[43],$sl[43],$KL2,0);
407         &RIP3($B,$C,$D,$E,$A,$wl[44],$sl[44],$KL2,0);
408         &RIP3($A,$B,$C,$D,$E,$wl[45],$sl[45],$KL2,0);
409         &RIP3($E,$A,$B,$C,$D,$wl[46],$sl[46],$KL2,0);
410         &RIP3($D,$E,$A,$B,$C,$wl[47],$sl[47],$KL2,1);
411
412         &RIP4($C,$D,$E,$A,$B,$wl[48],$sl[48],$KL3,-1);
413         &RIP4($B,$C,$D,$E,$A,$wl[49],$sl[49],$KL3,0);
414         &RIP4($A,$B,$C,$D,$E,$wl[50],$sl[50],$KL3,0);
415         &RIP4($E,$A,$B,$C,$D,$wl[51],$sl[51],$KL3,0);
416         &RIP4($D,$E,$A,$B,$C,$wl[52],$sl[52],$KL3,0);
417         &RIP4($C,$D,$E,$A,$B,$wl[53],$sl[53],$KL3,0);
418         &RIP4($B,$C,$D,$E,$A,$wl[54],$sl[54],$KL3,0);
419         &RIP4($A,$B,$C,$D,$E,$wl[55],$sl[55],$KL3,0);
420         &RIP4($E,$A,$B,$C,$D,$wl[56],$sl[56],$KL3,0);
421         &RIP4($D,$E,$A,$B,$C,$wl[57],$sl[57],$KL3,0);
422         &RIP4($C,$D,$E,$A,$B,$wl[58],$sl[58],$KL3,0);
423         &RIP4($B,$C,$D,$E,$A,$wl[59],$sl[59],$KL3,0);
424         &RIP4($A,$B,$C,$D,$E,$wl[60],$sl[60],$KL3,0);
425         &RIP4($E,$A,$B,$C,$D,$wl[61],$sl[61],$KL3,0);
426         &RIP4($D,$E,$A,$B,$C,$wl[62],$sl[62],$KL3,0);
427         &RIP4($C,$D,$E,$A,$B,$wl[63],$sl[63],$KL3,1);
428
429         &RIP5($B,$C,$D,$E,$A,$wl[64],$sl[64],$KL4,-1);
430         &RIP5($A,$B,$C,$D,$E,$wl[65],$sl[65],$KL4,0);
431         &RIP5($E,$A,$B,$C,$D,$wl[66],$sl[66],$KL4,0);
432         &RIP5($D,$E,$A,$B,$C,$wl[67],$sl[67],$KL4,0);
433         &RIP5($C,$D,$E,$A,$B,$wl[68],$sl[68],$KL4,0);
434         &RIP5($B,$C,$D,$E,$A,$wl[69],$sl[69],$KL4,0);
435         &RIP5($A,$B,$C,$D,$E,$wl[70],$sl[70],$KL4,0);
436         &RIP5($E,$A,$B,$C,$D,$wl[71],$sl[71],$KL4,0);
437         &RIP5($D,$E,$A,$B,$C,$wl[72],$sl[72],$KL4,0);
438         &RIP5($C,$D,$E,$A,$B,$wl[73],$sl[73],$KL4,0);
439         &RIP5($B,$C,$D,$E,$A,$wl[74],$sl[74],$KL4,0);
440         &RIP5($A,$B,$C,$D,$E,$wl[75],$sl[75],$KL4,0);
441         &RIP5($E,$A,$B,$C,$D,$wl[76],$sl[76],$KL4,0);
442         &RIP5($D,$E,$A,$B,$C,$wl[77],$sl[77],$KL4,0);
443         &RIP5($C,$D,$E,$A,$B,$wl[78],$sl[78],$KL4,0);
444         &RIP5($B,$C,$D,$E,$A,$wl[79],$sl[79],$KL4,1);
445
446         # &mov($tmp2,   &wparam(0)); # moved into last RIP5
447         # &mov(&swtmp(16),      $A);
448          &mov($A,       &DWP( 0,$tmp2,"",0));
449         &mov(&swtmp(16+1),      $B);
450          &mov(&swtmp(16+2),     $C);
451         &mov($B,        &DWP( 4,$tmp2,"",0));
452          &mov(&swtmp(16+3),     $D);
453         &mov($C,        &DWP( 8,$tmp2,"",0));
454          &mov(&swtmp(16+4),     $E);
455         &mov($D,        &DWP(12,$tmp2,"",0));
456          &mov($E,       &DWP(16,$tmp2,"",0));
457
458         &RIP5($A,$B,$C,$D,$E,$wr[ 0],$sr[ 0],$KR0,-2);
459         &RIP5($E,$A,$B,$C,$D,$wr[ 1],$sr[ 1],$KR0,0);
460         &RIP5($D,$E,$A,$B,$C,$wr[ 2],$sr[ 2],$KR0,0);
461         &RIP5($C,$D,$E,$A,$B,$wr[ 3],$sr[ 3],$KR0,0);
462         &RIP5($B,$C,$D,$E,$A,$wr[ 4],$sr[ 4],$KR0,0);
463         &RIP5($A,$B,$C,$D,$E,$wr[ 5],$sr[ 5],$KR0,0);
464         &RIP5($E,$A,$B,$C,$D,$wr[ 6],$sr[ 6],$KR0,0);
465         &RIP5($D,$E,$A,$B,$C,$wr[ 7],$sr[ 7],$KR0,0);
466         &RIP5($C,$D,$E,$A,$B,$wr[ 8],$sr[ 8],$KR0,0);
467         &RIP5($B,$C,$D,$E,$A,$wr[ 9],$sr[ 9],$KR0,0);
468         &RIP5($A,$B,$C,$D,$E,$wr[10],$sr[10],$KR0,0);
469         &RIP5($E,$A,$B,$C,$D,$wr[11],$sr[11],$KR0,0);
470         &RIP5($D,$E,$A,$B,$C,$wr[12],$sr[12],$KR0,0);
471         &RIP5($C,$D,$E,$A,$B,$wr[13],$sr[13],$KR0,0);
472         &RIP5($B,$C,$D,$E,$A,$wr[14],$sr[14],$KR0,0);
473         &RIP5($A,$B,$C,$D,$E,$wr[15],$sr[15],$KR0,2);
474
475         &RIP4($E,$A,$B,$C,$D,$wr[16],$sr[16],$KR1,-2);
476         &RIP4($D,$E,$A,$B,$C,$wr[17],$sr[17],$KR1,0);
477         &RIP4($C,$D,$E,$A,$B,$wr[18],$sr[18],$KR1,0);
478         &RIP4($B,$C,$D,$E,$A,$wr[19],$sr[19],$KR1,0);
479         &RIP4($A,$B,$C,$D,$E,$wr[20],$sr[20],$KR1,0);
480         &RIP4($E,$A,$B,$C,$D,$wr[21],$sr[21],$KR1,0);
481         &RIP4($D,$E,$A,$B,$C,$wr[22],$sr[22],$KR1,0);
482         &RIP4($C,$D,$E,$A,$B,$wr[23],$sr[23],$KR1,0);
483         &RIP4($B,$C,$D,$E,$A,$wr[24],$sr[24],$KR1,0);
484         &RIP4($A,$B,$C,$D,$E,$wr[25],$sr[25],$KR1,0);
485         &RIP4($E,$A,$B,$C,$D,$wr[26],$sr[26],$KR1,0);
486         &RIP4($D,$E,$A,$B,$C,$wr[27],$sr[27],$KR1,0);
487         &RIP4($C,$D,$E,$A,$B,$wr[28],$sr[28],$KR1,0);
488         &RIP4($B,$C,$D,$E,$A,$wr[29],$sr[29],$KR1,0);
489         &RIP4($A,$B,$C,$D,$E,$wr[30],$sr[30],$KR1,0);
490         &RIP4($E,$A,$B,$C,$D,$wr[31],$sr[31],$KR1,2);
491
492         &RIP3($D,$E,$A,$B,$C,$wr[32],$sr[32],$KR2,-2);
493         &RIP3($C,$D,$E,$A,$B,$wr[33],$sr[33],$KR2,0);
494         &RIP3($B,$C,$D,$E,$A,$wr[34],$sr[34],$KR2,0);
495         &RIP3($A,$B,$C,$D,$E,$wr[35],$sr[35],$KR2,0);
496         &RIP3($E,$A,$B,$C,$D,$wr[36],$sr[36],$KR2,0);
497         &RIP3($D,$E,$A,$B,$C,$wr[37],$sr[37],$KR2,0);
498         &RIP3($C,$D,$E,$A,$B,$wr[38],$sr[38],$KR2,0);
499         &RIP3($B,$C,$D,$E,$A,$wr[39],$sr[39],$KR2,0);
500         &RIP3($A,$B,$C,$D,$E,$wr[40],$sr[40],$KR2,0);
501         &RIP3($E,$A,$B,$C,$D,$wr[41],$sr[41],$KR2,0);
502         &RIP3($D,$E,$A,$B,$C,$wr[42],$sr[42],$KR2,0);
503         &RIP3($C,$D,$E,$A,$B,$wr[43],$sr[43],$KR2,0);
504         &RIP3($B,$C,$D,$E,$A,$wr[44],$sr[44],$KR2,0);
505         &RIP3($A,$B,$C,$D,$E,$wr[45],$sr[45],$KR2,0);
506         &RIP3($E,$A,$B,$C,$D,$wr[46],$sr[46],$KR2,0);
507         &RIP3($D,$E,$A,$B,$C,$wr[47],$sr[47],$KR2,2,$wr[48]);
508
509         &RIP2($C,$D,$E,$A,$B,$wr[48],$wr[49],$sr[48],$KR3,-2);
510         &RIP2($B,$C,$D,$E,$A,$wr[49],$wr[50],$sr[49],$KR3,0);
511         &RIP2($A,$B,$C,$D,$E,$wr[50],$wr[51],$sr[50],$KR3,0);
512         &RIP2($E,$A,$B,$C,$D,$wr[51],$wr[52],$sr[51],$KR3,0);
513         &RIP2($D,$E,$A,$B,$C,$wr[52],$wr[53],$sr[52],$KR3,0);
514         &RIP2($C,$D,$E,$A,$B,$wr[53],$wr[54],$sr[53],$KR3,0);
515         &RIP2($B,$C,$D,$E,$A,$wr[54],$wr[55],$sr[54],$KR3,0);
516         &RIP2($A,$B,$C,$D,$E,$wr[55],$wr[56],$sr[55],$KR3,0);
517         &RIP2($E,$A,$B,$C,$D,$wr[56],$wr[57],$sr[56],$KR3,0);
518         &RIP2($D,$E,$A,$B,$C,$wr[57],$wr[58],$sr[57],$KR3,0);
519         &RIP2($C,$D,$E,$A,$B,$wr[58],$wr[59],$sr[58],$KR3,0);
520         &RIP2($B,$C,$D,$E,$A,$wr[59],$wr[60],$sr[59],$KR3,0);
521         &RIP2($A,$B,$C,$D,$E,$wr[60],$wr[61],$sr[60],$KR3,0);
522         &RIP2($E,$A,$B,$C,$D,$wr[61],$wr[62],$sr[61],$KR3,0);
523         &RIP2($D,$E,$A,$B,$C,$wr[62],$wr[63],$sr[62],$KR3,0);
524         &RIP2($C,$D,$E,$A,$B,$wr[63],$wr[64],$sr[63],$KR3,2);
525
526         &RIP1($B,$C,$D,$E,$A,$wr[64],$sr[64],-2);
527         &RIP1($A,$B,$C,$D,$E,$wr[65],$sr[65],0);
528         &RIP1($E,$A,$B,$C,$D,$wr[66],$sr[66],0);
529         &RIP1($D,$E,$A,$B,$C,$wr[67],$sr[67],0);
530         &RIP1($C,$D,$E,$A,$B,$wr[68],$sr[68],0);
531         &RIP1($B,$C,$D,$E,$A,$wr[69],$sr[69],0);
532         &RIP1($A,$B,$C,$D,$E,$wr[70],$sr[70],0);
533         &RIP1($E,$A,$B,$C,$D,$wr[71],$sr[71],0);
534         &RIP1($D,$E,$A,$B,$C,$wr[72],$sr[72],0);
535         &RIP1($C,$D,$E,$A,$B,$wr[73],$sr[73],0);
536         &RIP1($B,$C,$D,$E,$A,$wr[74],$sr[74],0);
537         &RIP1($A,$B,$C,$D,$E,$wr[75],$sr[75],0);
538         &RIP1($E,$A,$B,$C,$D,$wr[76],$sr[76],0);
539         &RIP1($D,$E,$A,$B,$C,$wr[77],$sr[77],0);
540         &RIP1($C,$D,$E,$A,$B,$wr[78],$sr[78],0);
541         &RIP1($B,$C,$D,$E,$A,$wr[79],$sr[79],2);
542
543         # &mov($tmp2,   &wparam(0)); # Moved into last round
544
545          &mov($tmp1,    &DWP( 4,$tmp2,"",0));   # ctx->B
546         &add($D,        $tmp1);
547          &mov($tmp1,    &swtmp(16+2));          # $c
548         &add($D,        $tmp1);
549
550          &mov($tmp1,    &DWP( 8,$tmp2,"",0));   # ctx->C
551         &add($E,        $tmp1);
552          &mov($tmp1,    &swtmp(16+3));          # $d
553         &add($E,        $tmp1);
554
555          &mov($tmp1,    &DWP(12,$tmp2,"",0));   # ctx->D
556         &add($A,        $tmp1);
557          &mov($tmp1,    &swtmp(16+4));          # $e
558         &add($A,        $tmp1);
559
560
561          &mov($tmp1,    &DWP(16,$tmp2,"",0));   # ctx->E
562         &add($B,        $tmp1);
563          &mov($tmp1,    &swtmp(16+0));          # $a
564         &add($B,        $tmp1);
565
566          &mov($tmp1,    &DWP( 0,$tmp2,"",0));   # ctx->A
567         &add($C,        $tmp1);
568          &mov($tmp1,    &swtmp(16+1));          # $b
569         &add($C,        $tmp1);
570
571          &mov($tmp1,    &wparam(2));
572
573         &mov(&DWP( 0,$tmp2,"",0),       $D);
574          &mov(&DWP( 4,$tmp2,"",0),      $E);
575         &mov(&DWP( 8,$tmp2,"",0),       $A);
576          &sub($tmp1,1);
577         &mov(&DWP(12,$tmp2,"",0),       $B);
578          &mov(&DWP(16,$tmp2,"",0),      $C);
579
580         &jle(&label("get_out"));
581
582         &mov(&wparam(2),$tmp1);
583          &mov($C,       $A);
584         &mov($tmp1,     &wparam(1));
585          &mov($A,       $D);
586         &add($tmp1,     64);
587          &mov($B,       $E);
588         &mov(&wparam(1),$tmp1);
589
590         &jmp(&label("start"));
591
592         &set_label("get_out");
593
594         &stack_pop(16+5+6);
595
596         &pop("ebx");
597         &pop("ebp");
598         &pop("edi");
599         &pop("esi");
600         &ret();
601         &function_end_B($name);
602         }
603