spier@umd5.umd.edu (Lori Spier) (03/30/88)
does anyone out there have a PD sine/cosine function written in 68000 assembly language? I need one that will be VERY fast, for it will be called durring an interrupt (VBLANK). also, if I want to multiply a number in a data register, like D0, by, lets say 12, are these two sections of code equal for all cases (negative and positive numbers): muls #12,d0 and: add d0,d0 add d0,d0 move d0,d1 add d0,d0 add d1,d0 thanks for any help you can give. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Brett Bourbin, President Selgus Ltd. bitnet: bbourbin@umdd usenet: brett@rover.umd.edu
andrew@frip.gwd.tek.com (Andrew Klossner) (04/04/88)
"does anyone out there have a PD sine/cosine function written in 68000 assembly language? I need one that will be VERY fast, for it will be called durring an interrupt (VBLANK)." I've got a very fast function: table lookup. For example, if you can round the argument to the nearest degree, then a 90-element table suffices. If you need seven-digit accuracy, a table won't help. -=- Andrew Klossner (decvax!tektronix!tekecs!andrew) [UUCP] (andrew%tekecs.tek.com@relay.cs.net) [ARPA]
urjlew@ecsvax.UUCP (Rostyk Lewyckyj) (04/05/88)
In article <9887@tekecs.TEK.COM>, andrew@frip.gwd.tek.com (Andrew Klossner) writes: > > "does anyone out there have a PD sine/cosine function written > in 68000 assembly language? I need one that will be VERY fast, > for it will be called durring an interrupt (VBLANK)." > > I've got a very fast function: table lookup. For example, if you can > round the argument to the nearest degree, then a 90-element table > suffices. If you need seven-digit accuracy, a table won't help. > I would have sent this by mail to the person who posed the original question to which Mr. Klossner in replying, but the identity of that person is not in the posting. So here goes to the net. A lot depends on the speed of your machine relative to the length of the VBLANK interval. If you don't get ready made code then I suggest using a table of sine(x) 0<=x<=pi/2 with a Taylor's series expansion for interpolation between tabulated values. Using trig identities reduce the argument for which you want to calculate the sine to 0<=y<=pi/2. then if y=x+h where x is the nearest tabulated point. sin(x+h)=sin(x)+h*cos(x)-(h*h/2)sin(x) and cos(x)=sin(x+pi/2) which will also be a tabulated value if the x es are evenly spaced from 0 to pi/2. I think this will give you both the speed and accuracy you need. ----------------------------------------------- Reply-To: Rostyslaw Jarema Lewyckyj urjlew@ecsvax.UUCP , urjlew@tucc.bitnet or urjlew@tucc.tucc.edu (ARPA,SURA,NSF etc. internet) tel. (919)-962-9107
robinson@dewey.soe.berkeley.edu (Michael Robinson) (04/11/88)
In article <4872@ecsvax.UUCP> urjlew@ecsvax.UUCP (Rostyk Lewyckyj) writes: <In article <9887@tekecs.TEK.COM>, andrew@frip.gwd.tek.com (Andrew Klossner) writes: <> "does anyone out there have a PD sine/cosine function written <> in 68000 assembly language? I need one that will be VERY fast, <> for it will be called durring an interrupt (VBLANK)." <> <> I've got a very fast function: table lookup. For example, if you can <> round the argument to the nearest degree, then a 90-element table <> suffices. If you need seven-digit accuracy, a table won't help. < < If you don't get ready made code then I <suggest using a table of sine(x) 0<=x<=pi/2 with a Taylor's series <expansion for interpolation between tabulated values. If the prospect of calculating a Taylor series during a VBLANK is unappealing, you can do a simple first derivative interpolation using the very same table, and the identities, sin' = cos and cos' = -sin. With a 256 entry table, that should give you many bits of accuracy quickly. I hope you're using fixed point. ------------------------------------------------------------------------------ Michael Robinson USENET: ucbvax!ernie!robinson ARPA: robinson@ernie.berkeley.edu