Thread: Need help converting a function in asm.

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Oct 2012
Posts
4
Rep Power
0

Need help converting a function in asm.

Hello guys, I'm hoping somebody can help me convert this asm function into a psuedo.

The function ia just be a simple cubic interpolation.

void __cdecl NAVDATA__CubicInterpolate(int a1, int a2, double a3)
{

__asm
{
fld [ebp+arg_8]
fld st
fmul st, st(1)
}

_EAX = *(_DWORD *)a2;

__asm
{

fld qword ptr [eax+44h]
fld qword ptr [eax+0Ch]
fld qword ptr [eax+28h]
fld qword ptr [eax+60h]

fsub st, st(3)
fsub st, st(2)

fld st(5)
fmul st, st(1)
fmul st, st(5)

fld st(3)
fsub st, st(3)
fsubrp st(2), st

fxch st(5)
fmulp st(1), st
fxch st(2)

fsubrp st(1), st
fmulp st(3), st
fxch st(1)

}
}

I'm guessing the function is actually quite alot like this one below but i would like some help with the converting if theres any asm experts here.

double CubicInterpolate(double y0, double y1,double y2, double y3, double mu)
{
double a0, a1, a2, a3, mu2;

mu2 = mu * mu;
a0 = y3 - y2 - y0 + y1;
a1 = y0 - y1 - a0;
a2 = y2 - y0;
a3 = y1;

return (a0 * mu * mu2 + a1 * mu2 + a2 * mu + a3);
}

This is what i've done so far but im uncertain if it's correct:

var v = val * val; // fld st
// fmul st, st(1)

var a0, a1, a2, a3; //fld qword ptr [eax+44h]
//fld qword ptr [eax+0Ch]
//fld qword ptr [eax+28h]
//fld qword ptr [eax+60h]

a0 = y3 - y0 - y2 + y1; //fsub st, st(3)
//fsub st, st(2)

a1 = y1 - y0; //fmul st, st(1)
a2 = a0 - y0; //fmul st, st(5)

a3 = (y3 - y0) - (y0 - y2); //fsub st, st(3)
//fsubrp st(2), st

any help appreciated, thanks
2. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Sep 2012
Posts
11
Rep Power
0
Sorry can't help you,i'm a newbie and still learning a lot as possible.
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Oct 2012
Posts
4
Rep Power
0
That's alright, hopefully someone can figure it out!
4. Don't you think that cubic interpolation based on 4 points is a bit risky?
I'd go with 2 points and slopes or two points and concavities.