I have this old code to transform spherical to Cartesian 3D coordinates :
TDVector3D Cartesian3D_asm(const double &Theta, const double &Phi)
{
TDVector3D V;
__asm__
{
mov eax,[ebp+0x0C]
mov edx,[ebp+0x10]
fld qword ptr [eax] // ST0=T Theta
fsincos // ST1=sin(T) ST0=cos(T)
fxch ST(1) // ST1=cos(T) ST0=sin(T)
fld qword ptr [edx] // ST2=cos(T) ST1=sin(T) ST0=P Phi
fsincos // ST3=cos(T) ST2=sin(T) ST1=sin(P) ST0=cos(P)
fmul ST,ST(2) // ST3=cos(T) ST2=sin(T) ST1=sin(P) ST0=cos(P)*sin(T)
fstp qword ptr V.X // ST2=cos(T) ST1=sin(T) ST0=sin(P)
fmulp ST(1),ST // ST1=cos(T) ST0=sin(P)*sin(T)
fstp qword ptr V.Y // ST0=cos(T)
fstp qword ptr V.Z // Coprocesseur vide
fwait
}
return V;
}
with this TDVector3D struct :
typedef struct TDVector3D {
double X, Y, Z;
TDVector3D(double x, double y, double z): X(x), Y(y), Z(z) { }
} TDVector3D;
The no assembler code is :
TDVector3D Cartesian3D(const double &Theta, const double &Phi)
{
double X, Y, Z;
X = Y = sin(Theta);
X *= cos(Phi);
Y *= sin(Phi);
Z = cos(Theta);
return TDVector3D(X, Y, Z);
}
I found this sample for SinCos :
void SinCos(double Theta, double *sinT, double *cosT)
{
__asm__ ("fsincos" : "=t" (*cosT), "=u" (*sinT) : "0" (Theta));
}
I try to convert my old code but I am totally lost with "u", "0", "t" (who is who regarding ST0, ST1, ...).