If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Four Lines of Code

Hi. I had some basic questions about these four lines of code. I just want to confirm I'm understanding a few points correctly.

Code:

lea eax, [esp]
push eax
call dword ptr [edx]
mov edi, eax

Let's say eax was orginally 11 and line 1 made eax 22, would the eax on line 4...

1. ...be 11?
2. ...be 22 if the line 2 push instruction wasn't there?
3. ...be 22 if the line 2 and 3 weren't there whether the instruction on line 1 was lea or mov?
4. ...ever be impacted by the line 3 call?

Thanks for any help clarifying these points.

Last edited by Mr. Smith; August 24th, 2014 at 01:17 PM.
Reason: Clarity

Re: Four Lines of Code

the value after the call depends on what the call did.

for C/C++, eax typically holds the return value of the function assuming it's a function that returns a pointer, reference, or integer type. For any other return types "it depends".
even if the function returns void, the value can change, there is no requirement for functions to preserve the content of eax through a function call (unlike some other registers that are required to be preserved).