The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Farabi on August 03, 2010, 05:27:12 AM

Title: How many parameter I should push?
Post by: Farabi on August 03, 2010, 05:27:12 AM
I make a dll function using C like this


typedef float GLvector4f[4]; // Typedef's For VMatMult Procedure
typedef float GLmatrix16f[16];

void  DLL_EXPORT VMatMult( GLmatrix16f M,GLvector4f v)
{
GLfloat res[4]; // Hold Calculated Results
res[0]=M[ 0]*v[0]+M[ 4]*v[1]+M[ 8]*v[2]+M[12]*v[3];
res[1]=M[ 1]*v[0]+M[ 5]*v[1]+M[ 9]*v[2]+M[13]*v[3];
res[2]=M[ 2]*v[0]+M[ 6]*v[1]+M[10]*v[2]+M[14]*v[3];
res[3]=M[ 3]*v[0]+M[ 7]*v[1]+M[11]*v[2]+M[15]*v[3];
v[0]=res[0]; // Results Are Stored Back In v[]
v[1]=res[1];
v[2]=res[2];
v[3]=res[3]; // Homogenous Coordinate
}


And Im going to call it using ASM. How many parameter I should push?
Title: Re: How many parameter I should push?
Post by: ecube on August 03, 2010, 06:26:14 AM
looks like 2? but you may want to define it with the stdcall calling convention, as that is just cleaner overall.
Title: Re: How many parameter I should push?
Post by: Farabi on August 03, 2010, 01:42:58 PM
I used extern "C" code, if I used __stdcall there are mangling there.
Title: Re: How many parameter I should push?
Post by: Twister on August 04, 2010, 08:45:02 PM
Would it be best just to use pointers as parameters? You only have to push two parameters that way.