Hello,

I'm sorry if this is all ready answered somewhere, but I don't quite know what to search for and what I've been searching for hasn't really answered my specific problem. I'm dealing with Visual Studio 2008 and I believe x86 assembly thereby.

My problem is I've got a function:

_declspec(naked) void
f(unsigned int input,unsigned int *output)
{
__asm
{
.... code ...
}
}


I really don't know how to change the value of output. I'm really new to assembly and I'm really new to C++, so I'm not quite understanding how to change the data inside the *output pointer. I've seen during debugging that *output has a hex address, but I don't know how to move it into a register, and then use the register to change the value that *output points to...

If anyone can help, I would really appreciate it. I've been trying to look it up everywhere, but I haven't found anything explicit, or anything I understand!

Thanks,
FXL
Posted on 2009-05-18 12:19:09 by feminaexlux

_declspec(naked) void
f(unsigned int input,unsigned int *output)
{
__asm
{
mov edx,output
mov eax,input
mov ,eax
}
}
Posted on 2009-05-18 13:25:08 by Ultrano
Ultrano answer is perfect.

You said that you are new in C++, here's how you do it in C++. You don't really want to use inline assembly when you can use proper C.

_declspec(naked) void
f(unsigned int input,unsigned int *output)
{
*output = input;
}

Posted on 2009-05-18 14:22:33 by ChaperonNoir

Ultrano answer is perfect.

You said that you are new in C++, here's how you do it in C++. You don't really want to use inline assembly when you can use proper C.


Ah, it's actually for an assignment on recursion with assembly, so I can't code it out with just C++. The input is for computing factorials with a CALL procedure later in assembly, and the output is just to return the value stored in EAX from the CALL procedure.

Thanks for the help, I didn't know it was relatively simple like that.
Posted on 2009-05-18 14:53:43 by feminaexlux