O'Reilly logo

Windows Debugging: Practical Foundations by Dmitry Vostokov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 10. Frame Pointer and Local Variables

Stack Usage

In addition to storage for return addresses of CALL instructions stack is used to pass parameters to functions and store local variables. Stack is also used to save and restore values held in registers when we want to preserve them during some computation or across function calls. For example, suppose we want to do a multiplication but at the same time we have another valuable data in register EAX and EDX. The multiplication result will over-write EAX and EDX values and we temporarily put their values on stack:

mov eax, 10 mov edx, 20 ... ... ... ; now we want to preserve EAX and EDX push eax push edx imul edx mov dword ptr [result], eax pop edx ; pop in reverse order pop eax ; stack is LIFO ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required