4681
Axe / Re: Routines
« on: February 25, 2010, 10:15:08 pm »
Here is my (most likely unoptimised) Sin approximation routine. Since floating point numbers have not been implemented (yet?) I was forced to use a different approach. Input is in 10x and output is in 10x. For example to input 3.1 (PI ) you would input 31. And output is from -10 to 10. It also *does* loop, so your input can go beyond 2PI (63).
The code is meant to be used like this
Optimizations are welcome, i'm sure there are some
Code: [Select]
Lbl S
->A
A^64/16->B
A^16->A
If B=1 Or (B=3
16-A->A
End
A-(A*A*A/600)->A
If B>1
-A->A
End
A
Return
The code is meant to be used like this
Code: [Select]
31sub(S)->C //Will return 10x the sin of 3.1
Optimizations are welcome, i'm sure there are some