Most X86 assemblies (NSAM clearly) on code samples I see (also on people generated by GCC) I see what is said to be "setting the stack frame" in this way: < Pre>
main: / * setting stack frame * / push EBP Move EBP, ASP ... code goes here ... / * remove stack frame * / mov esp, ebp pop ebp < / Pre> I have 3 questions about this exercise:
-
If my code stays Does not touch the Mac, so the stack frame as above is totally useless, okay?
-
Even if my code uses a stack, till I pop everything (except for the heap, because it was essentially) A stack frame is completely useless, okay?
-
As I have seen that its sole purpose will be to save the value of ESP, so that I can play with it with me without worrying about things to mess things up, and once Am I restoring my original value just what is the purpose of this stack frame setup or am I missing something?
thanks
OK, actually , You do not need stack frames.
When you save the registers and store local variables in the stack - writing and debugging are easy: just set ebp to the stack at a fixed point and Find all stack data using ebp And finally it is easy to restore the esp . In addition, debugger often expects the presence of stack frames, otherwise you may get an incorrect stack call for example.
So, the answer to 1 is yes, the answer to 2 and 3 is above.
No comments:
Post a Comment