Subversion Repositories Kolibri OS

Rev

Rev 1764 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include <math.h>
  2. #include "kosSyst.h"
  3. extern "C" int _fltused = 0;
  4. double __cdecl acos(double x)
  5. {
  6.         __asm {
  7.                 fld     qword ptr [esp+4]
  8.                 fld1
  9.                 fadd    st, st(1)
  10.                 fld1
  11.                 fsub    st, st(2)
  12.                 fmulp   st(1), st
  13.                 fsqrt
  14.                 fxch    st(1)
  15.                 fpatan
  16.         }
  17. }
  18. double __cdecl asin(double x)
  19. {
  20.         __asm {
  21.                 fld     qword ptr [esp+4]
  22.                 fld1
  23.                 fadd    st, st(1)
  24.                 fld1
  25.                 fsub    st, st(2)
  26.                 fmulp   st(1), st
  27.                 fsqrt
  28.                 fpatan
  29.                 ret
  30.         }
  31. }
  32. #if _MSC_VER <= 1200
  33. extern "C" double _ftol(double x)
  34. {
  35.         __asm {
  36.                 fld     qword ptr [esp+4]
  37.                 push    1F3Fh
  38.                 fstcw   word ptr [esp+2]
  39.                 fldcw   word ptr [esp]
  40.                 frndint
  41.                 fldcw   word ptr [esp+2]
  42.                 add     esp, 4
  43.         }
  44. }
  45. #endif
  46. #pragma function(ceil)
  47. double __cdecl ceil(double x)
  48. {
  49.         __asm {
  50.                 fld     qword ptr [esp+4]
  51.                 push    1B3Fh
  52.                 fstcw   word ptr [esp+2]
  53.                 fldcw   word ptr [esp]
  54.                 frndint
  55.                 fldcw   word ptr [esp+2]
  56.                 add     esp, 4
  57.         }
  58. }
  59.  
  60. double __cdecl floor(double x)
  61. {
  62.         __asm {
  63.                 fld     qword ptr [esp+4]
  64.                 push    173Fh
  65.                 fstcw   word ptr [esp+2]
  66.                 fldcw   word ptr [esp]
  67.                 frndint
  68.                 fldcw   word ptr [esp+2]
  69.                 add     esp, 4
  70.         }
  71. }
  72.  
  73. double __cdecl round(double x)
  74. {
  75.         __asm {
  76.                 fld     qword ptr [esp+4]
  77.                 push    133Fh
  78.                 fstcw   word ptr [esp+2]
  79.                 fldcw   word ptr [esp]
  80.                 frndint
  81.                 fldcw   word ptr [esp+2]
  82.                 add     esp, 4
  83.         }
  84. }
  85.