/ frexp.s (emx+gcc) -- Copyright (c) 1992-1993 by Steffen Haecker
/                      Modified 1993-1996 by Eberhard Mattes

#include <emx/asm386.h>

#define FUNC    MATHSUFFIX1(frexp)

        .globl  LABEL(FUNC)

        .text

        ALIGN

/ 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

LABEL(FUNC):
        PROFILE_NOFRAME
        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)
        EPILOGUE(FUNC)
