s_copysign.S revision 1.6
11.1Sjtc/*
21.6Ssalo * Written by J.T. Conklin <jtc@NetBSD.org>.
31.3Sjtc * Public domain.
41.1Sjtc */
51.1Sjtc
61.5Sfvdl/*
71.5Sfvdl * XXXfvdl might as well split this file.
81.5Sfvdl */
91.5Sfvdl
101.1Sjtc#include <machine/asm.h>
111.1Sjtc
121.6SsaloRCSID("$NetBSD: s_copysign.S,v 1.6 2003/07/26 19:25:01 salo Exp $")
131.5Sfvdl
141.5Sfvdl#ifdef __x86_64__
151.5Sfvdl.Lpos:
161.5Sfvdl	.quad	0x8000000000000000
171.5Sfvdl.Lneg:
181.5Sfvdl	.quad	0x7fffffffffffffff
191.5Sfvdl#endif
201.5Sfvdl
211.2Sjtc
221.1SjtcENTRY(copysign)
231.5Sfvdl#ifdef __i386__
241.1Sjtc	movl	16(%esp),%edx
251.1Sjtc	andl	$0x80000000,%edx
261.1Sjtc	movl	8(%esp),%eax
271.1Sjtc	andl	$0x7fffffff,%eax
281.1Sjtc	orl	%edx,%eax
291.1Sjtc	movl	%eax,8(%esp)
301.1Sjtc	fldl	4(%esp)
311.5Sfvdl#else
321.5Sfvdl#if 0
331.5Sfvdl	/*
341.5Sfvdl	 * XXXfvdl gas doesn't grok this yet.
351.5Sfvdl	 */
361.5Sfvdl	movq	.Lpos(%rip),%xmm2
371.5Sfvdl	movq	.Lneg(%rip),%xmm3
381.5Sfvdl	pand	%xmm2,%xmm1
391.5Sfvdl	pand	%xmm3,%xmm0
401.5Sfvdl	por	%xmm1,%xmm0
411.5Sfvdl#else
421.5Sfvdl	movsd	%xmm0,-8(%rsp)
431.5Sfvdl	movsd	%xmm1,-16(%rsp)
441.5Sfvdl	movl	-12(%rsp),%edx
451.5Sfvdl	andl	$0x80000000,%edx
461.5Sfvdl	movl	-4(%rsp),%eax
471.5Sfvdl	andl	$0x7fffffff,%eax
481.5Sfvdl	orl	%edx,%eax
491.5Sfvdl	movl	%eax,-4(%rsp)
501.5Sfvdl	movsd	-8(%rsp),%xmm0
511.5Sfvdl#endif
521.5Sfvdl#endif
531.1Sjtc	ret
54