I have to write function in asm, and i have prototype in C
void fdct(float *in, float *out, unsigned int n);
Where:
in
: pointer to incoming data bufferout
: pointer to outcoming data buffern
: amount of data matrices.
Function doesn't return anything, but works with array of outcoming data and must change it according to result.
As I understand, in cdecl stack will look like:
esp: ret
esp+4: *in - address
esp+8: *out - address
esp+12: value of n
I got, how to work in asm with incoming buffer, but I don't understand how to return new address of outcoming buffer - just putting new address into esp+8
isn't resultive, it doesn't change value of *out
. How can I manage this problem?
That is not how this should work.
Your assembler function does not allocate a
float
(or an array offloat
) and return it inout
.Instead, the caller should allocate such an array (e.g. using
malloc()
,calloc()
-- or whatever functions his or her language provides -- or simply as local variable on the stack) and pass the address of the first element inout
. Your function just fills the array with suitablefloat
values, probably up ton
elements.Example: