assemblytrigonometrytaylor-series68hc11

Taylor series implementation in assembly language using 68hc11


How to implement Taylor series to calculate sine value in assembly using 68hc11.

As 68hc11 does not support floating point, display value will be in integer..(e.g. multiply by 100 to make integer value).


Solution

  • You might use an algorithm which does the calculation incremental, the following snippet should be easily transformed to fixpoint assembly since it makes no use of factorial and power functions. Usually it is easier to do this with lookup tables. Assembly code for 68HC11 to calculate sin(x)

    double taylorSin(double x,double epsilon) {
           double result = 0.0;
           double part_n = 0.0,part=x;
           result = part;
           int i = 1;
           while ( fabs( part - part_n ) > epsilon ) {
               part_n = part;
               part = (-part*x*x) / ((2*i)*(2*i+1));
               result += part;
               i++;
           }
           return result;
    }