/ fmod.s (emx+gcc) -- Copyright (c) 1992-1993 by Steffen Haecker
/                     Modified 1993 by Eberhard Mattes

#include <libm.h>

        .globl  FUN(fmod)

        .text

        .align  2, 0x90

/ 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

DEF(fmod)
        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:      ret
