A stack is a simple computational device with two operations, push and pop, that allows us to pile up data to remember it in LIFO (Last In First Out) manner and help in easy retrieval of the last piled data item as shown on Picture 9.1.
Figure 9.1. Picture 9.1
CPU ESP register (Stack Pointer) points to the top of a stack. As shown on Picture 9.2 a stack grows towards lower memory addresses with every push instruction and this is implemented as ESP register decrement by 4. We can read the top stack value using the following instruction: mov eax, [esp].
Figure 9.2. Picture ...