INSTALL.md: Restore $ as command prompt indicator
[oweals/openssl.git] / crypto / des / asm / des-586.pl
index de6013624fddf1acc1a9f71a1b69bc987022f531..fe51a227ca57f4f48a8967f4ef85c27920f5f042 100644 (file)
@@ -1,20 +1,28 @@
-#!/usr/local/bin/perl
+#! /usr/bin/env perl
+# Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
 #
+# Licensed under the Apache License 2.0 (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
+
 # The inner loop instruction sequence and the IP/FP modifications are from
-# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>
-#
+# Svend Olaf Mikkelsen.
 
-push(@INC,"perlasm","../../perlasm");
+$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
+push(@INC,"${dir}","${dir}../../perlasm");
 require "x86asm.pl";
 require "cbc.pl";
 require "desboth.pl";
 
-# base code is in microsft
+# base code is in Microsoft
 # op dest, source
 # format.
 #
 
-&asm_init($ARGV[0],"des-586.pl");
+$output=pop and open STDOUT,">$output";
+
+&asm_init($ARGV[0]);
 
 $L="edi";
 $R="esi";
@@ -23,6 +31,9 @@ $small_footprint=1 if (grep(/\-DOPENSSL_SMALL_FOOTPRINT/,@ARGV));
 # one can discuss setting this variable to 1 unconditionally, as
 # the folded loop is only 3% slower than unrolled, but >7 times smaller
 
+&public_label("DES_SPtrans");
+&static_label("des_sptrans");
+
 &DES_encrypt_internal();
 &DES_decrypt_internal();
 &DES_encrypt("DES_encrypt1",1);
@@ -35,6 +46,8 @@ $small_footprint=1 if (grep(/\-DOPENSSL_SMALL_FOOTPRINT/,@ARGV));
 
 &asm_finish();
 
+close STDOUT or die "error closing STDOUT: $!";
+
 sub DES_encrypt_internal()
        {
        &function_begin_B("_x86_DES_encrypt");
@@ -71,7 +84,7 @@ sub DES_encrypt_internal()
 
        &function_end_B("_x86_DES_encrypt");
        }
-       
+
 sub DES_decrypt_internal()
        {
        &function_begin_B("_x86_DES_decrypt");
@@ -108,7 +121,7 @@ sub DES_decrypt_internal()
 
        &function_end_B("_x86_DES_decrypt");
        }
-       
+
 sub DES_encrypt
        {
        local($name,$do_ip)=@_;
@@ -152,7 +165,10 @@ sub DES_encrypt
                }
 
        # PIC-ification:-)
-       &picmeup($trans,"DES_SPtrans");
+       &call   (&label("pic_point"));
+       &set_label("pic_point");
+       &blindpop($trans);
+       &lea    ($trans,&DWP(&label("des_sptrans")."-".&label("pic_point"),$trans));
 
        &mov(   "ecx",  &wparam(1)      );
 
@@ -266,7 +282,7 @@ sub IP_new
        &R_PERM_OP($l,$tt,$r,14,"0x33333333",$r);
        &R_PERM_OP($tt,$r,$l,22,"0x03fc03fc",$r);
        &R_PERM_OP($l,$r,$tt, 9,"0xaaaaaaaa",$r);
-       
+
        if ($lr != 3)
                {
                if (($lr-3) < 0)
@@ -308,8 +324,8 @@ sub FP_new
 
 sub DES_SPtrans
        {
-       &public_label("DES_SPtrans");
        &set_label("DES_SPtrans",64);
+       &set_label("des_sptrans");
        &data_word(0x02080800, 0x00080000, 0x02000002, 0x02080802);
        &data_word(0x02000000, 0x00080802, 0x00080002, 0x02000002);
        &data_word(0x00080802, 0x02080800, 0x02080000, 0x00000802);