MyFunction PROC arg1:DWORD, arg2:DWORD
In C/C++ all integral return values are returned in EAX and all floating point return values are returned in ST(0).
//Declare prototype for MyFunction
//Specify C to prevent name mangling
//Specify extern because the body of this function lies outside of
//the current module
extern "C" MyFunction(DWORD arg1,DWORD arg2);
Also you should know which calling mode is being used as this determines in what order the parameters are pushed onto the stack.
But for all 32-bit programs:
EBP - last value of EBP
EBP+4 - address of caller - return address
EBP+8 - first parameter starts here
When mixing pure assembly code and C/C++ you will always want to use the following if you are doing anything with parameters:
Note this is TASM syntax, not MASM:
Failing to do this will crash the compiler and perhaps even Windows - yes, even XP. This is a requirement in TASM when using the ARG directive and I'm sure it probably is in MASM as well.
;always start with this
;always end with this
NASM also must conform to this standard in order to function correctly when being mixed with C/C++ code.