Copyright consolidation: perl files
[openssl.git] / crypto / md5 / asm / md5-586.pl
index 5fc6a205ce00af8843d1ec750d5397dd50567374..24f68af546acb7a21453daa1f463566bba0a1f78 100644 (file)
@@ -1,4 +1,11 @@
-#!/usr/local/bin/perl
+#! /usr/bin/env perl
+# Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the OpenSSL license (the "License").  You may not use
+# this file except in compliance with the License.  You can obtain a copy
+# in the file LICENSE in the source distribution or at
+# https://www.openssl.org/source/license.html
+
 
 # Normal is the
 # md5_block_x86(MD5_CTX *c, ULONG *X);
@@ -7,9 +14,13 @@
 
 $normal=0;
 
-push(@INC,"perlasm","../../perlasm");
+$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
+push(@INC,"${dir}","${dir}../../perlasm");
 require "x86asm.pl";
 
+$output=pop;
+open STDOUT,">$output";
+
 &asm_init($ARGV[0],$0);
 
 $A="eax";
@@ -29,9 +40,11 @@ $X="esi";
  0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9, # R3
  );
 
-&md5_block("md5_block_asm_host_order");
+&md5_block("md5_block_asm_data_order");
 &asm_finish();
 
+close STDOUT;
+
 sub Np
        {
        local($p)=@_;
@@ -55,14 +68,14 @@ sub R0
        &lea($a,&DWP($t,$a,$tmp2,1));
 
        &xor($tmp1,$d); # F function - part 4
+       &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if ($pos != 2);
 
        &add($a,$tmp1);
-       &mov($tmp1,&Np($c)) if $pos < 1;        # next tmp1 for R0
-       &mov($tmp1,&Np($c)) if $pos == 1;       # next tmp1 for R1
 
        &rotl($a,$s);
 
-       &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if ($pos != 2);
+       &mov($tmp1,&Np($c)) if $pos < 1;        # next tmp1 for R0
+       &mov($tmp1,&Np($c)) if $pos == 1;       # next tmp1 for R1
 
        &add($a,$b);
        }
@@ -73,13 +86,12 @@ sub R1
 
        &comment("R1 $ki");
 
-       &lea($a,&DWP($t,$a,$tmp2,1));
-
        &xor($tmp1,$b); # G function - part 2
        &and($tmp1,$d); # G function - part 3
+       &lea($a,&DWP($t,$a,$tmp2,1));
 
-       &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if ($pos != 2);
        &xor($tmp1,$c);                 # G function - part 4
+       &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if ($pos != 2);
 
        &add($a,$tmp1);
        &mov($tmp1,&Np($c)) if $pos < 1;        # G function - part 1
@@ -107,10 +119,10 @@ if (($n & 1) == 0)
        &lea($a,&DWP($t,$a,$tmp2,1));
 
        &add($a,$tmp1);
+       &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0));
 
        &rotl($a,$s);
 
-       &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0));
        &mov($tmp1,&Np($c));
        }
 else
@@ -119,11 +131,11 @@ else
        # make sure to do 'D' first, not 'B', else we clash with
        # the last add from the previous round.
 
-       &lea($a,&DWP($t,$a,$tmp2,1));
-
        &add($b,$c);                    # MOVED FORWARD
        &xor($tmp1,$d); # H function - part 2
 
+       &lea($a,&DWP($t,$a,$tmp2,1));
+
        &xor($tmp1,$b); # H function - part 3
        &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if ($pos != 2);
 
@@ -293,7 +305,7 @@ sub md5_block
         &mov(&DWP(12,$tmp2,"",0),$D);
 
        &cmp($tmp1,$X) unless $normal;                  # check count
-        &jge(&label("start")) unless $normal;
+        &jae(&label("start")) unless $normal;
 
        &pop("eax"); # pop the temp variable off the stack
         &pop("ebx");