Okay, if a function in a dll is supposed to have a return value, and the c header had the return value defined, how will i access this return value through asm, will the value be in one of the registers? if the dll is supposed to return the value to the calling function then i dont understand how i can do this through asm.
Posted on 2005-07-10 12:06:56 by mkdsctt
Return values are always in eax. Even in dll, you do the same - you return the values by placing them in eax before you exit the function
Posted on 2005-07-10 12:45:59 by roticv
so then really what c does is just move eax to whatever variable you have designated to receive the return value? except it does it automatically without the user even needing to know what eax is?
Posted on 2005-07-10 12:47:41 by mkdsctt
int foo() {
return someVar;? ?//? This places someVar's value into eax
int bar() {
int resultOfFoo=foo();? //foo() is called.? When foo() exists, the result is left in eax.? eax is then copied to resultOfFoo.
foo();? /* eax after this call to foo() also contains the value of someVar.? If you use in-line assembly immediately after this statement, you should you should still be able to access the value returned by foo() in eax.? So you're right, the C-programmer doesn't need to worry about eax. :)
The compiler copies the contents of eax to the receiving variable after return from the call.
Posted on 2005-07-10 13:25:50 by jademtech
...or to st(0) if you return a float/double under cdecl calling conv.
Posted on 2005-07-10 13:59:49 by ti_mo_n