Platform update from 8-stable.
[openssl.git] / crypto / perlasm / x86unix.pl
index c34cd74b7a1141730ab0618bd8f10546c949dde1..9bc5c0e893cf23eca692347f4ab31dff6e805d50 100644 (file)
@@ -161,12 +161,13 @@ sub main'shl      { &out2("sall",@_); }
 sub main'shr   { &out2("shrl",@_); }
 sub main'xor   { &out2("xorl",@_); }
 sub main'xorb  { &out2("xorb",@_); }
-sub main'add   { &out2("addl",@_); }
+sub main'add   { &out2($_[0]=~/%[a-d][lh]/?"addb":"addl",@_); }
 sub main'adc   { &out2("adcl",@_); }
 sub main'sub   { &out2("subl",@_); }
+sub main'sbb   { &out2("sbbl",@_); }
 sub main'rotl  { &out2("roll",@_); }
 sub main'rotr  { &out2("rorl",@_); }
-sub main'exch  { &out2("xchg",@_); }
+sub main'exch  { &out2($_[0]=~/%[a-d][lh]/?"xchgb":"xchgl",@_); }
 sub main'cmp   { &out2("cmpl",@_); }
 sub main'lea   { &out2("leal",@_); }
 sub main'mul   { &out1("mull",@_); }
@@ -188,11 +189,11 @@ sub main'jc       { &out1("jc",@_); }
 sub main'jnc   { &out1("jnc",@_); }
 sub main'jno   { &out1("jno",@_); }
 sub main'dec   { &out1("decl",@_); }
-sub main'inc   { &out1("incl",@_); }
+sub main'inc   { &out1($_[0]=~/%[a-d][hl]/?"incb":"incl",@_); }
 sub main'push  { &out1("pushl",@_); $stack+=4; }
 sub main'pop   { &out1("popl",@_); $stack-=4; }
-sub main'pushf { &out0("pushf"); $stack+=4; }
-sub main'popf  { &out0("popf"); $stack-=4; }
+sub main'pushf { &out0("pushfl"); $stack+=4; }
+sub main'popf  { &out0("popfl"); $stack-=4; }
 sub main'not   { &out1("notl",@_); }
 sub main'call  {       my $pre=$under;
                        foreach $i (%label)
@@ -204,8 +205,12 @@ sub main'nop       { &out0("nop"); }
 sub main'test  { &out2("testl",@_); }
 sub main'bt    { &out2("btl",@_); }
 sub main'leave { &out0("leave"); }
-sub main'cpuid { &out0(".word\t0xa20f"); }
-sub main'rdtsc { &out0(".word\t0x310f"); }
+sub main'cpuid { &out0(".byte\t0x0f,0xa2"); }
+sub main'rdtsc { &out0(".byte\t0x0f,0x31"); }
+sub main'halt  { &out0("hlt"); }
+sub main'movz  { &out2("movzbl",@_); }
+sub main'neg   { &out1("negl",@_); }
+sub main'cld   { &out0("cld"); }
 
 # SSE2
 sub main'emms  { &out0("emms"); }
@@ -495,6 +500,12 @@ sub main'comment
                }
        }
 
+sub main'public_label
+       {
+       $label{$_[0]}="${under}${_[0]}" if (!defined($label{$_[0]}));
+       push(@out,".globl\t$label{$_[0]}\n");
+       }
+
 sub main'label
        {
        if (!defined($label{$_[0]}))
@@ -526,7 +537,8 @@ sub main'file_end
        if ($main'elf && grep {/%[x]*mm[0-7]/i} @out) {
                local($tmp);
 
-               push (@out,"\n.comm\t${under}OPENSSL_ia32cap_P,4,4\n");
+               push (@out,"\n.section\t.bss\n");
+               push (@out,".comm\t${under}OPENSSL_ia32cap_P,4,4\n");
 
                push (@out,".section\t.init\n");
                # One can argue that it's wasteful to craft every
@@ -550,18 +562,19 @@ sub main'file_end
                pushf
                popl    %eax
                xorl    %ecx,%eax
-               bt      \$21,%eax
+               btl     \$21,%eax
                jnc     1f
                pushl   %edi
                pushl   %ebx
                movl    %edx,%edi
                movl    \$1,%eax
-               .word   0xa20f
+               .byte   0x0f,0xa2
                orl     \$1<<10,%edx
                movl    %edx,0(%edi)
                popl    %ebx
                popl    %edi
-       .align  4
+               jmp     1f
+       .align  $align
        1:
 ___
                push (@out,$tmp);
@@ -706,6 +719,9 @@ sub main'initseg
                $tmp=<<___;
 .section       .init
        call    $under$f
+       jmp     .Linitalign
+.align $align
+.Linitalign:
 ___
                }
        elsif ($main'coff)