August 24th, 2014, 01:16 PM
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.
Let's say eax was orginally 11 and line 1 made eax 22, would the eax on line 4...
lea eax, [esp]
call dword ptr [edx]
mov edi, eax
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.
August 25th, 2014, 07:03 AM
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).
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!