views:

239

answers:

2

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).

+1  A: 

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. http://stackoverflow.com/questions/1959335/assembly-code-for-68hc11-to-calculate-sinx

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;
}
stacker
A: 

The Taylor series is probably not your best option. Take a look at CORDIC.

starblue