Blame sysdeps/i386/fpu/s_frexp.S

Packit 6c4009
/* ix87 specific frexp implementation for 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 <machine/asm.h>
Packit 6c4009
#include <libm-alias-double.h>
Packit 6c4009
Packit 6c4009
	.section .rodata
Packit 6c4009
Packit 6c4009
	.align ALIGNARG(4)
Packit 6c4009
	.type two54,@object
Packit 6c4009
two54:	.byte 0, 0, 0, 0, 0, 0, 0x50, 0x43
Packit 6c4009
	ASM_SIZE_DIRECTIVE(two54)
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 EXPP	VAL1+4
Packit 6c4009
Packit 6c4009
	.text
Packit 6c4009
ENTRY (__frexp)
Packit 6c4009
Packit 6c4009
	movl	VAL0(%esp), %ecx
Packit 6c4009
	movl	VAL1(%esp), %eax
Packit 6c4009
	movl	%eax, %edx
Packit 6c4009
	andl	$0x7fffffff, %eax
Packit 6c4009
	orl	%eax, %ecx
Packit 6c4009
	jz	1f
Packit 6c4009
	xorl	%ecx, %ecx
Packit 6c4009
	cmpl	$0x7ff00000, %eax
Packit 6c4009
	jae	1f
Packit 6c4009
Packit 6c4009
	cmpl	$0x00100000, %eax
Packit 6c4009
	jae	2f
Packit 6c4009
Packit 6c4009
	fldl	VAL0(%esp)
Packit 6c4009
#ifdef	PIC
Packit 6c4009
	LOAD_PIC_REG (dx)
Packit 6c4009
#endif
Packit 6c4009
	fmull	MO(two54)
Packit 6c4009
	movl	$-54, %ecx
Packit 6c4009
	fstpl	VAL0(%esp)
Packit 6c4009
	fwait
Packit 6c4009
	movl	VAL1(%esp), %eax
Packit 6c4009
	movl	%eax, %edx
Packit 6c4009
	andl	$0x7fffffff, %eax
Packit 6c4009
Packit 6c4009
2:	shrl	$20, %eax
Packit 6c4009
	andl	$0x800fffff, %edx
Packit 6c4009
	subl	$1022, %eax
Packit 6c4009
	orl	$0x3fe00000, %edx
Packit 6c4009
	addl	%eax, %ecx
Packit 6c4009
	movl	%edx, VAL1(%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
	fldl	VAL0(%esp)
Packit 6c4009
	movl	%ecx, (%eax)
Packit 6c4009
Packit 6c4009
	ret
Packit 6c4009
END (__frexp)
Packit 6c4009
libm_alias_double (__frexp, frexp)