*
* *
*
scene.org
Log in:
login for 1 year
No account? register here

Scene.org is hosted and supported by:
Hogeschool Rotterdam
Scene.org is sponsored by:
Pixar Animation Studios
* forum - #coders

*
Topic:  Sin/Cos in Assembler?
* Posted by ChewieRFC Saturday 2 May 2009 - 9:58 
How did one compute sines and cosines in x86 assembler before the advent of the FPU? For example, to program a plasma demo in assembly without using fcos and fsin. Was it all pre-programmed look-up tables or the use of Taylor series? I'm curious, I can't find much information on it.

* Posted by psenough Tuesday 5 May 2009 - 11:00 
pre calculated lookup tables and fixed point

* Posted by dakoder Sunday 30 August 2009 - 0:25 
Hi Chewie, PS is correct you do use preset values please have a look at this pdf and look at page 53 which shows the SINCOS table set up


http://www.dakoder.co.uk/edu/4/mmx_project.pdf


how it works is simple...... no honest it really is..

take two 4 bit registers A and B
let a=1000 which is binary for 8
let b=0000 which is zero
now A:B = 1000:0000 = 8.0
KEEP SHIFTING TO THE RIGHT
now A:B = 0100:0000 = 4.0
shift again (dividing by 2)

now A:B = 0010:0000 = 2.0
again shift
A:B = 0001:0000 = 1.0

NOW SHIFT AGAIN WE SHOULD GET A HALF BECAUSE 1/2 = HALF
A:B = 0000:1000 = 0.5

shift again
A:B = 0000:0100 = 0.25

and therefore 0000:1100 = 0.5+0.25 = 0.75

and so on, the sincos table you see is the B register, which means that cos(0)=0.999999999 forever which is almost 1
hope this helps

Dakoder

*