Padlock engine: make it independent of inline assembler.
[openssl.git] / crypto / perlasm / x86masm.pl
index 2e2b3152c3c56405a9a1401554bbe540c8de6bc5..ee446de5c1d036544a5a543a66367a03a2717413 100644 (file)
@@ -14,7 +14,7 @@ sub ::generic
 { my ($opcode,@arg)=@_;
 
     # fix hexadecimal constants
-    for (@arg) { s/0x([0-9a-f]+)/0$1h/oi; }
+    for (@arg) { s/(?<![\w\$\.])0x([0-9a-f]+)/0$1h/oi; }
 
     if ($opcode !~ /movq/)
     {  # fix xmm references
@@ -31,6 +31,7 @@ sub ::generic
 sub ::call     { &::emit("call",(&::islabel($_[0]) or "$nmdecor$_[0]")); }
 sub ::call_ptr { &::emit("call",@_);   }
 sub ::jmp_ptr  { &::emit("jmp",@_);    }
+sub ::lock     { &::data_byte(0xf0);   }
 
 sub get_mem
 { my($size,$addr,$reg1,$reg2,$idx)=@_;
@@ -65,6 +66,7 @@ sub get_mem
   $ret;
 }
 sub ::BP       { &get_mem("BYTE",@_);  }
+sub ::WP       { &get_mem("WORD",@_);  }
 sub ::DWP      { &get_mem("DWORD",@_); }
 sub ::QWP      { &get_mem("QWORD",@_); }
 sub ::BC       { "@_";  }
@@ -128,7 +130,7 @@ ___
 
     if (grep {/\b${nmdecor}OPENSSL_ia32cap_P\b/i} @out)
     {  my $comm=<<___;
-.bss   SEGMENT
+.bss   SEGMENT 'BSS'
 COMM   ${nmdecor}OPENSSL_ia32cap_P:QWORD
 .bss   ENDS
 ___
@@ -156,6 +158,9 @@ sub ::public_label
 sub ::data_byte
 {   push(@out,("DB\t").join(',',@_)."\n");     }
 
+sub ::data_short
+{   push(@out,("DW\t").join(',',@_)."\n");     }
+
 sub ::data_word
 {   push(@out,("DD\t").join(',',@_)."\n");     }
 
@@ -181,4 +186,11 @@ ___
 sub ::dataseg
 {   push(@out,"$segment\tENDS\n_DATA\tSEGMENT\n"); $segment="_DATA";   }
 
+sub ::safeseh
+{ my $nm=shift;
+    push(@out,"IF \@Version GE 710\n");
+    push(@out,".SAFESEH        ".&::LABEL($nm,$nmdecor.$nm)."\n");
+    push(@out,"ENDIF\n");
+}
+
 1;