Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

#1
October 3rd, 2012, 04:52 AM
 wren11
Registered User

Join Date: Oct 2012
Posts: 4
Time spent in forums: 52 m 17 sec
Reputation 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
October 3rd, 2012, 05:05 AM
 Edward25
Registered User

Join Date: Sep 2012
Posts: 12
Time spent in forums: 4 h 11 m 21 sec
Reputation Power: 0
Sorry can't help you,i'm a newbie and still learning a lot as possible.

#3
October 3rd, 2012, 05:21 AM
 wren11
Registered User

Join Date: Oct 2012
Posts: 4
Time spent in forums: 52 m 17 sec
Reputation Power: 0
That's alright, hopefully someone can figure it out!

#4
October 3rd, 2012, 12:15 PM
 b49P23TIvg
Contributing User

Join Date: Aug 2011
Posts: 3,460
Time spent in forums: 1 Month 2 Weeks 4 Days 6 h 56 m 42 sec
Reputation Power: 403
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.
__________________
[code]Code tags[/code] are essential for python code!

 Viewing: Dev Shed Forums > Programming Languages > C Programming > Need help converting a function in asm.