summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/perlasm/x86unix.pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/perlasm/x86unix.pl')
-rw-r--r--src/lib/libcrypto/perlasm/x86unix.pl83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/lib/libcrypto/perlasm/x86unix.pl b/src/lib/libcrypto/perlasm/x86unix.pl
index 10a7af8bff..9ceabf0705 100644
--- a/src/lib/libcrypto/perlasm/x86unix.pl
+++ b/src/lib/libcrypto/perlasm/x86unix.pl
@@ -3,6 +3,8 @@
3package x86unix; 3package x86unix;
4 4
5$label="L000"; 5$label="L000";
6$const="";
7$constl=0;
6 8
7$align=($main'aout)?"4":"16"; 9$align=($main'aout)?"4":"16";
8$under=($main'aout)?"_":""; 10$under=($main'aout)?"_":"";
@@ -162,6 +164,8 @@ sub main'dec { &out1("decl",@_); }
162sub main'inc { &out1("incl",@_); } 164sub main'inc { &out1("incl",@_); }
163sub main'push { &out1("pushl",@_); $stack+=4; } 165sub main'push { &out1("pushl",@_); $stack+=4; }
164sub main'pop { &out1("popl",@_); $stack-=4; } 166sub main'pop { &out1("popl",@_); $stack-=4; }
167sub main'pushf { &out0("pushf"); $stack+=4; }
168sub main'popf { &out0("popf"); $stack-=4; }
165sub main'not { &out1("notl",@_); } 169sub main'not { &out1("notl",@_); }
166sub main'call { &out1("call",$under.$_[0]); } 170sub main'call { &out1("call",$under.$_[0]); }
167sub main'ret { &out0("ret"); } 171sub main'ret { &out0("ret"); }
@@ -344,6 +348,7 @@ sub main'function_end
344.${func}_end: 348.${func}_end:
345EOF 349EOF
346 push(@out,$tmp); 350 push(@out,$tmp);
351
347 if ($main'cpp) 352 if ($main'cpp)
348 { push(@out,"\tSIZE($func,.${func}_end-$func)\n"); } 353 { push(@out,"\tSIZE($func,.${func}_end-$func)\n"); }
349 elsif ($main'gaswin) 354 elsif ($main'gaswin)
@@ -453,9 +458,87 @@ sub main'set_label
453 458
454sub main'file_end 459sub main'file_end
455 { 460 {
461 if ($const ne "")
462 {
463 push(@out,".section .rodata\n");
464 push(@out,$const);
465 $const="";
466 }
456 } 467 }
457 468
458sub main'data_word 469sub main'data_word
459 { 470 {
460 push(@out,"\t.long $_[0]\n"); 471 push(@out,"\t.long $_[0]\n");
461 } 472 }
473
474# debug output functions: puts, putx, printf
475
476sub main'puts
477 {
478 &pushvars();
479 &main'push('$Lstring' . ++$constl);
480 &main'call('puts');
481 $stack-=4;
482 &main'add("esp",4);
483 &popvars();
484
485 $const .= "Lstring$constl:\n\t.string \"@_[0]\"\n";
486 }
487
488sub main'putx
489 {
490 &pushvars();
491 &main'push($_[0]);
492 &main'push('$Lstring' . ++$constl);
493 &main'call('printf');
494 &main'add("esp",8);
495 $stack-=8;
496 &popvars();
497
498 $const .= "Lstring$constl:\n\t.string \"\%X\"\n";
499 }
500
501sub main'printf
502 {
503 $ostack = $stack;
504 &pushvars();
505 for ($i = @_ - 1; $i >= 0; $i--)
506 {
507 if ($i == 0) # change this to support %s format strings
508 {
509 &main'push('$Lstring' . ++$constl);
510 $const .= "Lstring$constl:\n\t.string \"@_[$i]\"\n";
511 }
512 else
513 {
514 if ($_[$i] =~ /([0-9]*)\(%esp\)/)
515 {
516 &main'push(($1 + $stack - $ostack) . '(%esp)');
517 }
518 else
519 {
520 &main'push($_[$i]);
521 }
522 }
523 }
524 &main'call('printf');
525 $stack-=4*@_;
526 &main'add("esp",4*@_);
527 &popvars();
528 }
529
530sub pushvars
531 {
532 &main'pushf();
533 &main'push("edx");
534 &main'push("ecx");
535 &main'push("eax");
536 }
537
538sub popvars
539 {
540 &main'pop("eax");
541 &main'pop("ecx");
542 &main'pop("edx");
543 &main'popf();
544 }