perlasm/x86* update: support for 3 and 4 argument instructions.
[openssl.git] / crypto / perlasm / x86masm.pl
index 94eee5a76d63f46858e3856f83bf555218f87421..4eca7bc367f04ad22a286d90afc93430b7101a29 100644 (file)
@@ -8,13 +8,13 @@ $::lbdecor="\$L";     # local label decoration
 $nmdecor="_";          # external name decoration
 
 $initseg="";
 $nmdecor="_";          # external name decoration
 
 $initseg="";
+$segment="";
 
 sub ::generic
 { my ($opcode,@arg)=@_;
 
     # fix hexadecimal constants
 
 sub ::generic
 { my ($opcode,@arg)=@_;
 
     # fix hexadecimal constants
-    $arg[0] =~ s/0x([0-9a-f]+)/0$1h/oi if (defined($arg[0]));
-    $arg[1] =~ s/0x([0-9a-f]+)/0$1h/oi if (defined($arg[1]));
+    for (@arg) { s/0x([0-9a-f]+)/0$1h/oi; }
 
     # fix xmm references
     $arg[0] =~ s/\b[A-Z]+WORD\s+PTR/XMMWORD PTR/i if ($arg[1]=~/\bxmm[0-7]\b/i);
 
     # fix xmm references
     $arg[0] =~ s/\b[A-Z]+WORD\s+PTR/XMMWORD PTR/i if ($arg[1]=~/\bxmm[0-7]\b/i);
@@ -78,12 +78,13 @@ ENDIF
 .MODEL FLAT
 OPTION DOTNAME
 IF \@Version LT 800
 .MODEL FLAT
 OPTION DOTNAME
 IF \@Version LT 800
-.text\$ SEGMENT PAGE 'CODE'
+.text\$        SEGMENT PAGE 'CODE'
 ELSE
 .text\$        SEGMENT ALIGN(64) 'CODE'
 ENDIF
 ___
     push(@out,$tmp);
 ELSE
 .text\$        SEGMENT ALIGN(64) 'CODE'
 ENDIF
 ___
     push(@out,$tmp);
+    $segment = ".text\$";
 }
 
 sub ::function_begin_B
 }
 
 sub ::function_begin_B
@@ -92,7 +93,7 @@ sub ::function_begin_B
   my $begin="${::lbdecor}_${func}_begin";
 
     &::LABEL($func,$global?"$begin":"$nmdecor$func");
   my $begin="${::lbdecor}_${func}_begin";
 
     &::LABEL($func,$global?"$begin":"$nmdecor$func");
-    $func=$nmdecor.$func."\tPROC";
+    $func="ALIGN\t16\n".$nmdecor.$func."\tPROC";
 
     if ($global)    { $func.=" PUBLIC\n${begin}::\n"; }
     else           { $func.=" PRIVATE\n";            }
 
     if ($global)    { $func.=" PUBLIC\n${begin}::\n"; }
     else           { $func.=" PRIVATE\n";            }
@@ -121,7 +122,7 @@ ___
        grep {s/\.[3-7]86/$xmmheader/} @out;
     }
 
        grep {s/\.[3-7]86/$xmmheader/} @out;
     }
 
-    push(@out,".text\$ ENDS\n");
+    push(@out,"$segment        ENDS\n");
 
     if (grep {/\b${nmdecor}OPENSSL_ia32cap_P\b/i} @out)
     {  my $comm=<<___;
 
     if (grep {/\b${nmdecor}OPENSSL_ia32cap_P\b/i} @out)
     {  my $comm=<<___;
@@ -175,4 +176,7 @@ DD  $f
 ___
 }
 
 ___
 }
 
+sub ::dataseg
+{   push(@out,"$segment\tENDS\n_DATA\tSEGMENT\n"); $segment="_DATA";   }
+
 1;
 1;