-
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. :)
-
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).