Update perl asm scripts include paths for perlasm.
[openssl.git] / crypto / des / asm / crypt586.pl
index 197c413..e36f7d4 100644 (file)
@@ -6,7 +6,8 @@
 # things perfect.
 #
 
-push(@INC,"perlasm","../../perlasm");
+$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
+push(@INC,"${dir}","${dir}../../perlasm");
 require "x86asm.pl";
 
 &asm_init($ARGV[0],"crypt586.pl");
@@ -14,7 +15,7 @@ require "x86asm.pl";
 $L="edi";
 $R="esi";
 
-&external_label("des_SPtrans");
+&external_label("DES_SPtrans");
 &fcrypt_body("fcrypt_body");
 &asm_finish();
 
@@ -22,15 +23,22 @@ sub fcrypt_body
        {
        local($name,$do_ip)=@_;
 
-       &function_begin($name,"EXTRN   _des_SPtrans:DWORD");
+       &function_begin($name);
 
        &comment("");
        &comment("Load the 2 words");
-       $ks="ebp";
+       $trans="ebp";
 
        &xor(   $L,     $L);
        &xor(   $R,     $R);
-       &mov($ks,&wparam(1));
+
+       # PIC-ification:-)
+       &picmeup("edx","DES_SPtrans");
+       #if ($cpp)      { &picmeup("edx","DES_SPtrans");   }
+       #else           { &lea("edx",&DWP("DES_SPtrans")); }
+       &push("edx");   # becomes &swtmp(1)
+       #
+       &mov($trans,&wparam(1)); # reloaded with DES_SPtrans in D_ENCRYPT
 
        &push(&DWC(25)); # add a variable
 
@@ -39,11 +47,11 @@ sub fcrypt_body
                {
                &comment("");
                &comment("Round $i");
-               &D_ENCRYPT($i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
+               &D_ENCRYPT($i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx");
 
                &comment("");
                &comment("Round ".sprintf("%d",$i+1));
-               &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
+               &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$trans,"eax","ebx","ecx","edx");
                }
         &mov("ebx",    &swtmp(0));
        &mov("eax",     $L);
@@ -61,14 +69,14 @@ sub fcrypt_body
        &mov(&DWP(0,"edx","",0),"eax");
        &mov(&DWP(4,"edx","",0),$L);
 
-       &pop("ecx");    # remove variable
+       &add("esp",8);  # remove variables
 
        &function_end($name);
        }
 
 sub D_ENCRYPT
        {
-       local($r,$L,$R,$S,$ks,$desSP,$u,$tmp1,$tmp2,$t)=@_;
+       local($r,$L,$R,$S,$trans,$u,$tmp1,$tmp2,$t)=@_;
 
        &mov(   $u,             &wparam(2));                    # 2
        &mov(   $t,             $R);
@@ -85,9 +93,9 @@ sub D_ENCRYPT
        &shl(   $tmp2,          16);                            # 1
        &xor(   $u,             $tmp1);                         # 2
        &xor(   $t,             $tmp2);                         # 2
-       &mov(   $tmp1,          &DWP(&n2a($S*4),$ks,"",0));     # 2
+       &mov(   $tmp1,          &DWP(&n2a($S*4),$trans,"",0));  # 2
        &xor(   $u,             $tmp1);
-       &mov(   $tmp2,          &DWP(&n2a(($S+1)*4),$ks,"",0)); # 2
+       &mov(   $tmp2,          &DWP(&n2a(($S+1)*4),$trans,"",0));      # 2
        &xor(   $u,             $R);
        &xor(   $t,             $R);
        &xor(   $t,             $tmp2);
@@ -99,31 +107,28 @@ sub D_ENCRYPT
        &movb(  &LB($tmp1),     &LB($u) );
        &movb(  &LB($tmp2),     &HB($u) );
        &rotr(  $t,             4               );
-       &mov(   $ks,            &DWP("      $desSP",$tmp1,"",0));
+       &mov(   $trans,         &swtmp(1));
+       &xor(   $L,             &DWP("     ",$trans,$tmp1,0));
        &movb(  &LB($tmp1),     &LB($t) );
-       &xor(   $L,             $ks);
-       &mov(   $ks,            &DWP("0x200+$desSP",$tmp2,"",0));
-       &xor(   $L,             $ks);
+       &xor(   $L,             &DWP("0x200",$trans,$tmp2,0));
        &movb(  &LB($tmp2),     &HB($t) );
        &shr(   $u,             16);
-       &mov(   $ks,            &DWP("0x100+$desSP",$tmp1,"",0));
-       &xor(   $L,             $ks); 
+       &xor(   $L,             &DWP("0x100",$trans,$tmp1,0));
        &movb(  &LB($tmp1),     &HB($u) );
        &shr(   $t,             16);
-       &mov(   $ks,            &DWP("0x300+$desSP",$tmp2,"",0));
-       &xor(   $L,             $ks);
-       &mov(   $ks,            &wparam(1));
+       &xor(   $L,             &DWP("0x300",$trans,$tmp2,0));
        &movb(  &LB($tmp2),     &HB($t) );
        &and(   $u,             "0xff"  );
        &and(   $t,             "0xff"  );
-       &mov(   $tmp1,          &DWP("0x600+$desSP",$tmp1,"",0));
+       &mov(   $tmp1,          &DWP("0x600",$trans,$tmp1,0));
        &xor(   $L,             $tmp1);
-       &mov(   $tmp1,          &DWP("0x700+$desSP",$tmp2,"",0));
+       &mov(   $tmp1,          &DWP("0x700",$trans,$tmp2,0));
        &xor(   $L,             $tmp1);
-       &mov(   $tmp1,          &DWP("0x400+$desSP",$u,"",0));
+       &mov(   $tmp1,          &DWP("0x400",$trans,$u,0));
        &xor(   $L,             $tmp1);
-       &mov(   $tmp1,          &DWP("0x500+$desSP",$t,"",0));
+       &mov(   $tmp1,          &DWP("0x500",$trans,$t,0));
        &xor(   $L,             $tmp1);
+       &mov(   $trans,         &wparam(1));
        }
 
 sub n2a