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