summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/asm/bn-586.pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bn/asm/bn-586.pl')
-rw-r--r--src/lib/libcrypto/bn/asm/bn-586.pl84
1 files changed, 77 insertions, 7 deletions
diff --git a/src/lib/libcrypto/bn/asm/bn-586.pl b/src/lib/libcrypto/bn/asm/bn-586.pl
index 19d425ee96..5191bed273 100644
--- a/src/lib/libcrypto/bn/asm/bn-586.pl
+++ b/src/lib/libcrypto/bn/asm/bn-586.pl
@@ -1,18 +1,16 @@
1#!/usr/bin/perl
2#
3
4#!/usr/local/bin/perl 1#!/usr/local/bin/perl
5 2
6push(@INC,"perlasm","../../perlasm"); 3push(@INC,"perlasm","../../perlasm");
7require "x86asm.pl"; 4require "x86asm.pl";
8 5
9&asm_init($ARGV[0],"bn-586.pl"); 6&asm_init($ARGV[0],$0);
10 7
11&bn_mul_add_words("bn_mul_add_words"); 8&bn_mul_add_words("bn_mul_add_words");
12&bn_mul_words("bn_mul_words"); 9&bn_mul_words("bn_mul_words");
13&bn_sqr_words("bn_sqr_words"); 10&bn_sqr_words("bn_sqr_words");
14&bn_div64("bn_div64"); 11&bn_div_words("bn_div_words");
15&bn_add_words("bn_add_words"); 12&bn_add_words("bn_add_words");
13&bn_sub_words("bn_sub_words");
16 14
17&asm_finish(); 15&asm_finish();
18 16
@@ -228,7 +226,7 @@ sub bn_sqr_words
228 &function_end($name); 226 &function_end($name);
229 } 227 }
230 228
231sub bn_div64 229sub bn_div_words
232 { 230 {
233 local($name)=@_; 231 local($name)=@_;
234 232
@@ -307,7 +305,79 @@ sub bn_add_words
307 } 305 }
308 &set_label("aw_end",0); 306 &set_label("aw_end",0);
309 307
310 &mov("eax",$c); 308# &mov("eax",$c); # $c is "eax"
309
310 &function_end($name);
311 }
312
313sub bn_sub_words
314 {
315 local($name)=@_;
316
317 &function_begin($name,"");
318
319 &comment("");
320 $a="esi";
321 $b="edi";
322 $c="eax";
323 $r="ebx";
324 $tmp1="ecx";
325 $tmp2="edx";
326 $num="ebp";
327
328 &mov($r,&wparam(0)); # get r
329 &mov($a,&wparam(1)); # get a
330 &mov($b,&wparam(2)); # get b
331 &mov($num,&wparam(3)); # get num
332 &xor($c,$c); # clear carry
333 &and($num,0xfffffff8); # num / 8
334
335 &jz(&label("aw_finish"));
336
337 &set_label("aw_loop",0);
338 for ($i=0; $i<8; $i++)
339 {
340 &comment("Round $i");
341
342 &mov($tmp1,&DWP($i*4,$a,"",0)); # *a
343 &mov($tmp2,&DWP($i*4,$b,"",0)); # *b
344 &sub($tmp1,$c);
345 &mov($c,0);
346 &adc($c,$c);
347 &sub($tmp1,$tmp2);
348 &adc($c,0);
349 &mov(&DWP($i*4,$r,"",0),$tmp1); # *r
350 }
351
352 &comment("");
353 &add($a,32);
354 &add($b,32);
355 &add($r,32);
356 &sub($num,8);
357 &jnz(&label("aw_loop"));
358
359 &set_label("aw_finish",0);
360 &mov($num,&wparam(3)); # get num
361 &and($num,7);
362 &jz(&label("aw_end"));
363
364 for ($i=0; $i<7; $i++)
365 {
366 &comment("Tail Round $i");
367 &mov($tmp1,&DWP($i*4,$a,"",0)); # *a
368 &mov($tmp2,&DWP($i*4,$b,"",0));# *b
369 &sub($tmp1,$c);
370 &mov($c,0);
371 &adc($c,$c);
372 &sub($tmp1,$tmp2);
373 &adc($c,0);
374 &dec($num) if ($i != 6);
375 &mov(&DWP($i*4,$r,"",0),$tmp1); # *a
376 &jz(&label("aw_end")) if ($i != 6);
377 }
378 &set_label("aw_end",0);
379
380# &mov("eax",$c); # $c is "eax"
311 381
312 &function_end($name); 382 &function_end($name);
313 } 383 }