/ frexp.s (emx+gcc) -- Copyright (c) 1992-1993 by Steffen Haecker
/                      Modified 1993 by Eberhard Mattes

#include <libm.h>

        .globl  FUN(frexp)

        .text

        .align  2, 0x90

/ double frexp (double x, int *exp_ptr)

#define x       4(%esp)
#if defined (LONG_DOUBLE)
#define exp_ptr 16(%esp)
#else
#define exp_ptr 12(%esp)
#endif

DEF(frexp)
	movl	exp_ptr, %edx
	movl	$0, (%edx)
	fldl    __const_M_ONE           / -1
        FLD     x                       / x
	ftst
	fstsww	%ax
	andw	$0x4100, %ax
	xorb	$0x40, %ah
	jz	1f			/ x = 0 ?
	fxtract
        fxch    %st(1)
	fistpl	(%edx)
        fscale
	incl	(%edx)
1:	fstp	%st(1)
	ret
