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

#include <emx/asm386.h>

#define FUNC    MATHSUFFIX1(fmod)

        .globl  LABEL(FUNC)

        .text

        ALIGN

/ double fmod (double x, double y)

/define ret_addr  0(%esp)
#define x         4(%esp)
#if defined (LONG_DOUBLE)
#define y        16(%esp)
#else
#define y        12(%esp)
#endif

LABEL(FUNC):
        PROFILE_NOFRAME
        FLD     y                       /* y */
        ftst
        fstsww  %ax
        andw    $0x4100, %ax
        xorb    $0x40, %ah
        jz      2f                      /* y = 0 ? */
        FLD     x                       /* x */
1:      fprem
        fstsww  %ax
        andb    $0x04, %ah
        jnz     1b                      /* C2 != 0 ? */
        fstp    %st(1)
2:      EPILOGUE(FUNC)
