Merge branch 'vendor/XZ' into HEAD
[dragonfly.git] / lib / libm / arch / i386 / s_copysign.S
1 /*
2  * Written by J.T. Conklin <jtc@NetBSD.org>.
3  * Public domain.
4  *
5  * $NetBSD: s_copysign.S,v 1.6 2003/07/26 19:25:01 salo Exp $
6  * $DragonFly: src/lib/libm/arch/i386/s_copysign.S,v 1.1 2005/07/26 21:15:19 joerg Exp $
7  */
8
9 /*
10  * XXXfvdl might as well split this file.
11  */
12
13 #include <machine/asm.h>
14
15 #ifdef __x86_64__
16 .Lpos:
17         .quad   0x8000000000000000
18 .Lneg:
19         .quad   0x7fffffffffffffff
20 #endif
21
22
23 ENTRY(copysign)
24 #ifdef __i386__
25         movl    16(%esp),%edx
26         andl    $0x80000000,%edx
27         movl    8(%esp),%eax
28         andl    $0x7fffffff,%eax
29         orl     %edx,%eax
30         movl    %eax,8(%esp)
31         fldl    4(%esp)
32 #else
33 #if 0
34         /*
35          * XXXfvdl gas doesn't grok this yet.
36          */
37         movq    .Lpos(%rip),%xmm2
38         movq    .Lneg(%rip),%xmm3
39         pand    %xmm2,%xmm1
40         pand    %xmm3,%xmm0
41         por     %xmm1,%xmm0
42 #else
43         movsd   %xmm0,-8(%rsp)
44         movsd   %xmm1,-16(%rsp)
45         movl    -12(%rsp),%edx
46         andl    $0x80000000,%edx
47         movl    -4(%rsp),%eax
48         andl    $0x7fffffff,%eax
49         orl     %edx,%eax
50         movl    %eax,-4(%rsp)
51         movsd   -8(%rsp),%xmm0
52 #endif
53 #endif
54         ret