Guest User

Untitled

a guest
Apr 16th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <iostream>
  4. double sinus(double q, int eps1)
  5. {
  6.     const double pi=3.14159265357989323846433;
  7.     double x=q,a2,eps,ten=10;
  8.     if (fabs(x)>2*pi)
  9.     {  
  10.         a2=x/(2*pi);
  11.         a2=ceil(a2);
  12.         x-=a2*2*pi;
  13.     }
  14.     _asm
  15.     {
  16.         mov ecx,eps1
  17.         finit
  18.         fclex
  19.         fld ten
  20.         fld ten
  21. de:     fmul st,st(1)
  22.         loop de
  23.         fxch st(1)
  24.         fld1
  25.         fdiv st,st(2)
  26.         fstp eps
  27.         fld x
  28.         fxch st(3)
  29.         fstp ten
  30.         fldz
  31.         fxch st(3)
  32.         fadd st(3),st
  33.         fmul x
  34.         fxch st(2)
  35.         fstp ten
  36.         fld x
  37.         mov eax,1
  38. taylor: fmul st,st(2)
  39.         fxch st(4)
  40.         mov ebx,eax
  41.         shl ebx,1
  42.         push eax
  43.         mov eax,ebx
  44.         inc ebx
  45.         mul ebx
  46.         mov ebx,1
  47.         div ebx
  48.         mov ebx,eax
  49.         pop eax
  50.         fstp ten
  51.         mov eps1,ebx
  52.         fild eps1
  53.         fxch st(4)
  54.         fdiv st,st(4)
  55.         fstp ten
  56.         fld ten
  57.         fabs
  58.         fcomp eps
  59.         push eax
  60.         fstsw ax
  61.         sahf
  62.         pop eax
  63.         jc end
  64.         fld ten
  65.         mov ebx,1
  66.         and ebx,eax
  67.         test ebx,ebx
  68.         jnz a1
  69.         fadd st(3),st
  70.         jmp a
  71. a1:     fsub st(3),st
  72. a:      inc eax
  73.         jmp taylor
  74. end:    fxch st(2)
  75.     }
  76. }
Add Comment
Please, Sign In to add comment