Blame sysdeps/i386/fpu/s_frexpl.S

Packit 6c4009
/* ix87 specific frexp implementation for long double.
Packit 6c4009
   Copyright (C) 1997-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <libm-alias-ldouble.h>
Packit 6c4009
#include <machine/asm.h>
Packit 6c4009
Packit 6c4009
	.section .rodata
Packit 6c4009
Packit 6c4009
	.align ALIGNARG(4)
Packit 6c4009
	.type two64,@object
Packit 6c4009
two64:	.byte 0, 0, 0, 0, 0, 0, 0xf0, 0x43
Packit 6c4009
	ASM_SIZE_DIRECTIVE(two64)
Packit 6c4009
Packit 6c4009
#ifdef PIC
Packit 6c4009
#define MO(op) op##@GOTOFF(%edx)
Packit 6c4009
#else
Packit 6c4009
#define MO(op) op
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#define PARMS	4		/* no space for saved regs */
Packit 6c4009
#define VAL0	PARMS
Packit 6c4009
#define VAL1	VAL0+4
Packit 6c4009
#define VAL2	VAL1+4
Packit 6c4009
#define EXPP	VAL2+4
Packit 6c4009
Packit 6c4009
	.text
Packit 6c4009
ENTRY (__frexpl)
Packit 6c4009
Packit 6c4009
	movl	VAL0(%esp), %ecx
Packit 6c4009
	movl	VAL2(%esp), %eax
Packit 6c4009
	orl	VAL1(%esp), %ecx
Packit 6c4009
	movl	%eax, %edx
Packit 6c4009
	andl	$0x7fff, %eax
Packit 6c4009
	orl	%eax, %ecx
Packit 6c4009
	jz	1f
Packit 6c4009
	xorl	%ecx, %ecx
Packit 6c4009
	cmpl	$0x7fff, %eax
Packit 6c4009
	je	3f
Packit 6c4009
Packit 6c4009
	cmpl	$0, %eax
Packit 6c4009
	jne	2f
Packit 6c4009
Packit 6c4009
	fldt	VAL0(%esp)
Packit 6c4009
#ifdef	PIC
Packit 6c4009
	LOAD_PIC_REG (dx)
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
	fmull	MO(two64)	/* It's not necessary to use a 80bit factor */
Packit 6c4009
	movl	$-64, %ecx
Packit 6c4009
	fstpt	VAL0(%esp)
Packit 6c4009
	fwait
Packit 6c4009
	movl	VAL2(%esp), %eax
Packit 6c4009
	movl	%eax, %edx
Packit 6c4009
	andl	$0x7fff, %eax
Packit 6c4009
Packit 6c4009
2:	andl	$0x8000, %edx
Packit 6c4009
	subl	$16382, %eax
Packit 6c4009
	orl	$0x3ffe, %edx
Packit 6c4009
	addl	%eax, %ecx
Packit 6c4009
	movl	%edx, VAL2(%esp)
Packit 6c4009
Packit 6c4009
	/* Store %ecx in the variable pointed to by the second argument,
Packit 6c4009
	   get the factor from the stack and return.  */
Packit 6c4009
1:	movl	EXPP(%esp), %eax
Packit 6c4009
	fldt	VAL0(%esp)
Packit 6c4009
	movl	%ecx, (%eax)
Packit 6c4009
Packit 6c4009
	ret
Packit 6c4009
Packit 6c4009
	/* Infinity or NaN; ensure signaling NaNs are quieted.  */
Packit 6c4009
3:	movl	EXPP(%esp), %eax
Packit 6c4009
	fldt	VAL0(%esp)
Packit 6c4009
	fadd	%st
Packit 6c4009
	movl	%ecx, (%eax)
Packit 6c4009
	ret
Packit 6c4009
END (__frexpl)
Packit 6c4009
libm_alias_ldouble (__frexp, frexp)