 |
|
|
Scene.org is hosted and supported by:
|
|
|
|
Scene.org is sponsored by:
|
|
|
|
|
 |
forum - #coders |
|
 | | Topic: | Sin/Cos in Assembler? | | | | 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. | | |
| | pre calculated lookup tables and fixed point | | |
| 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 | | |
|
|
|