The stack is an area of the memory that gets allocated by the operating system when the thread is created. The stack is organized in a Last-In-First-Out (LIFO) structure, which means that the most recent data that you put in the stack will be the first one to be removed from the stack. You put data (called pushing) onto the stack by using the push instruction, and you remove data (called popping) from the stack using the pop instruction. The push instruction pushes a 4-byte value onto the stack, and the pop instruction pops a 4-byte value from the top of the stack. The general forms of the push and pop instructions are shown here:
push source ; pushes source on top of the stack
pop destination ; copies value from the top of the stack to the destination
The stack grows from higher addresses to lower addresses. This means when a stack is created, the esp register (also called the stack pointer) points to the top of the stack (higher address), and as you push data into the stack, the esp register decrements by 4 (esp-4) to a lower address. When you pop a value, the esp increments by 4 (esp+4). Let's look at the following assembly code and try to understand the inner workings of the stack:
push 3
push 4
pop ebx
pop edx
Before executing the preceding instructions, the esp register points to the top of the stack (for example, at address 0xff8c), as shown here:

After the first instruction is executed (push 3), ESP is decremented by 4 (because the push instruction pushes a 4-byte value onto the stack), and the value 3 is placed on the stack; now, ESP points to the top of the stack at 0xff88. After the second instruction (push 4), esp is decremented by 4; now, esp contains 0xff84, which is now the top of the stack. When pop ebx is executed, the value 4 from the top of the stack is moved to the ebx register, and esp is incremented by 4 (because pop removes a 4-byte value from the stack). So, esp now points to the stack at 0xff88. Similarly, when the pop edx instruction is executed, the value 3 from the top of the stack is placed in the edx register, and esp comes back to its original position at 0xff8c:

In the preceding diagram, the values popped from the stack are physically still present in memory, even though they are logically removed. Also, notice how the most recently pushed value (4) was the first to be removed.