rmd-586.pl 16 KB

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