/ modf.s (emx+gcc) -- Copyright (c) 1991-1993 by Eberhard Mattes

#include <libm.h>

        .globl  FUN(modf)

        .text

        .align  2, 0x90

/ double modf (double x, double *intptr)

#define cw1       0(%esp)
#define cw2       2(%esp)
/define ret_addr  4(%esp)
#define x         8(%esp)
#if defined (LONG_DOUBLE)
#define intptr   20(%esp)
#else
#define intptr   16(%esp)
#endif

DEF(modf)
        subl    $4, %esp
        fstcww  cw1
        movw    cw1, %ax
        orw     $0x0c00, %ax            / chop mode
        movw    %ax, cw2
        movl    intptr, %eax
        fldcww  cw2
        FLD     x                       / x
        fld     %st
        frndint
#if defined (LONG_DOUBLE)
        fld     %st                     / there is no fstt, use fstpt instead
        fstpt   (%eax)
#else
        fstl    (%eax)
#endif
        fldcww  cw1
        fsubrp
        addl    $4, %esp
        ret
