FPATAN question, is that THETA I see? x87 FPU Inline Assembly in C.

Started by OceanJeff32, October 18, 2005, 07:47:13 PM

Previous topic - Next topic

OceanJeff32

Ok, what the heck is FPATAN doing?

I load ST(0), with Y, then load ST(0) with X, then call FPATAN, which divides y/x, then gives me the angle who tangent is (y/x), that's what I want, but FPATAN doesn't do that.  The Intel manual says it stores the value in ST(1) then pops the stack, putting the value in ST(0).  So then I : FST to my toyt (theta variable), and print to screen, but I keep getting nonsense...

I've tried to understand the coordinate conversion that I'm doing, but  :snooty:

Just curious, I'll be pondering this one for a while tonight at work.

later,

jeff c
:bdg

P.S. The file and source code are attached.

[attachment deleted by admin]
Any good programmer knows, every large and/or small job, is equally large, to the programmer!

Eóin

Should work, you get the answer in radians, you may need to convert to degrees?

raymond

Quotebut I keep getting nonsense...

Maybe you should explain what you mean by nonsense. If the results seem wrong based on your input for toy1 and toy2, remember that you change the value of the toy1 variable by adding to it the value of the toy2 variable before you compute the radius and the angle.

/*   _asm {
fld toy1 // load to st(0)
fld toy2 // bump st0 to st1, and load to st(0)
fadd st, st(1) // adds st(1) to st(0)
fstp toy1 // store st(0) to toy1
emms // clears x87 MMX registers.
}


Raymond
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

OceanJeff32

Eoin, yes thanks, I forgot about radians, so I just have to take the angle, in radians, times by 180, and divide by PIE.

Raymond, oh, that part is commented out with /* */

thanks guys, i'll be posting more code on this and other trig functions, vector functions later,

jeff c
:U
Any good programmer knows, every large and/or small job, is equally large, to the programmer!