The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
Need help converting a function in asm.
Discuss Need help converting a function in asm. in the C Programming forum on Dev Shed. Need help converting a function in asm. C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

October 3rd, 2012, 04:52 AM
|
|
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)
fadd st, st(1)
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
faddp st(4), st
fxch st(2)
fsubrp st(1), st
fmulp st(3), st
fxch st(1)
faddp st(2), st
faddp st(1), st
}
}
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)
//fadd st, st(1)
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
|

October 3rd, 2012, 05:05 AM
|
|
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.
|

October 3rd, 2012, 05:21 AM
|
|
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!
|

October 3rd, 2012, 12:15 PM
|
 |
Contributing User
|
|
|
|
|
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!
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|