Timings.
[openssl.git] / crypto / perlasm / x86unix.pl
index efaef87a0b0f0d2ac120a5b5daff666c0bbc2624..309060ea001856b9eb8616b0edadffeb9b8660c4 100644 (file)
@@ -1,11 +1,5 @@
 #!/usr/local/bin/perl
 
-# Because the bswapl instruction is not supported for old assembers
-# (it was a new instruction for the 486), I've added .byte xxxx code
-# to put it in.
-# eric 24-Apr-1998
-#
-
 package x86unix;
 
 $label="L000";
@@ -106,6 +100,16 @@ sub main'BP
        return(&main'DWP(@_));
        }
 
+sub main'BC
+       {
+       return @_;
+       }
+
+sub main'DWC
+       {
+       return @_;
+       }
+
 #sub main'BP
 #      {
 #      local($addr,$reg1,$reg2,$idx)=@_;
@@ -158,12 +162,27 @@ sub main'dec      { &out1("decl",@_); }
 sub main'inc   { &out1("incl",@_); }
 sub main'push  { &out1("pushl",@_); $stack+=4; }
 sub main'pop   { &out1("popl",@_); $stack-=4; }
-sub main'bswap { &out1("bswapl",@_); }
 sub main'not   { &out1("notl",@_); }
 sub main'call  { &out1("call",$under.$_[0]); }
 sub main'ret   { &out0("ret"); }
 sub main'nop   { &out0("nop"); }
 
+# The bswapl instruction is new for the 486. Emulate if i386.
+sub main'bswap
+       {
+       if ($main'i386)
+               {
+               &main'comment("bswapl @_");
+               &main'exch(main'HB(@_),main'LB(@_));
+               &main'rotr(@_,16);
+               &main'exch(main'HB(@_),main'LB(@_));
+               }
+       else
+               {
+               &out1("bswapl",@_);
+               }
+       }
+
 sub out2
        {
        local($name,$p1,$p2)=@_;
@@ -273,6 +292,8 @@ EOF
        push(@out,$tmp);
        if ($main'cpp)
                { $tmp=push(@out,"\tTYPE($func,\@function)\n"); }
+       elsif ($main'gaswin)
+               { $tmp=push(@out,"\t.def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); }
        else    { $tmp=push(@out,"\t.type\t$func,\@function\n"); }
        push(@out,"$func:\n");
        $tmp=<<"EOF";
@@ -301,6 +322,8 @@ EOF
        push(@out,$tmp);
        if ($main'cpp)
                { push(@out,"\tTYPE($func,\@function)\n"); }
+       elsif ($main'gaswin)
+               { $tmp=push(@out,"\t.def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); }
        else    { push(@out,"\t.type    $func,\@function\n"); }
        push(@out,"$func:\n");
        $stack=4;
@@ -323,6 +346,8 @@ EOF
        push(@out,$tmp);
        if ($main'cpp)
                { push(@out,"\tSIZE($func,.${func}_end-$func)\n"); }
+       elsif ($main'gaswin)
+                { $tmp=push(@out,"\t.align 4\n"); }
        else    { push(@out,"\t.size\t$func,.${func}_end-$func\n"); }
        push(@out,".ident       \"$func\"\n");
        $stack=0;
@@ -349,10 +374,12 @@ sub main'function_end_B
 
        $func=$under.$func;
 
-       push(@out,".${func}_end:\n");
+       push(@out,".L_${func}_end:\n");
        if ($main'cpp)
-               { push(@out,"\tSIZE($func,.${func}_end-$func)\n"); }
-       else    { push(@out,"\t.size\t$func,.${func}_end-$func\n"); }
+               { push(@out,"\tSIZE($func,.L_${func}_end-$func)\n"); }
+        elsif ($main'gaswin)
+                { push(@out,"\t.align 4\n"); }
+       else    { push(@out,"\t.size\t$func,.L_${func}_end-$func\n"); }
        push(@out,".ident       \"desasm.pl\"\n");
        $stack=0;
        %label=();