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