Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Written by J.T. Conklin <jtc@netbsd.org>.
  3.  * Public domain.
  4.  *
  5.  * Adapted for float type by Danny Smith
  6.  *  <dannysmith@users.sourceforge.net>.
  7.  */
  8.  
  9. #include <math.h>
  10.  
  11. float
  12. fmodf (float x, float y)
  13. {
  14.   float res;
  15.  
  16.   asm ("1:\tfprem\n\t"
  17.        "fstsw   %%ax\n\t"
  18.        "sahf\n\t"
  19.        "jp      1b\n\t"
  20.        "fstp    %%st(1)"
  21.        : "=t" (res) : "0" (x), "u" (y) : "ax", "st(1)");
  22.   return res;
  23. }
  24.  
  25. double
  26. fmod (double x, double y)
  27. {
  28.   float res;
  29.  
  30.   asm ("1:\tfprem\n\t"
  31.        "fstsw   %%ax\n\t"
  32.        "sahf\n\t"
  33.        "jp      1b\n\t"
  34.        "fstp    %%st(1)"
  35.        : "=t" (res) : "0" (x), "u" (y) : "ax", "st(1)");
  36.   return res;
  37. }
  38.