About
The Stack Segment is a segment that holds a stack.
It's a stack implementation of memory locations.
As the stack is a segment, it is a contiguous array of memory locations.
Articles Related
Management
Addressing
When using:
- the flat memory model, the stack can be located anywhere in the linear address space for the program.
Operations (PUSH|POP)
Items are:
- placed on the stack using the PUSH instruction
- removed from the stack using the POP instruction.
When an item is:
- pushed onto the stack, the processor decrements the ESP register, then writes the item at the new top of stack.
- popped off the stack, the processor reads the item from the top of stack, then increments the ESP register.
In this manner, the stack:
- grows down in memory (towards lesser addresses) when items are pushed on the stack
- and shrinks up (towards greater addresses) when the items are popped from the stack.
Size
A stack can be up to 4 GBytes long, the maximum size of a segment.
Pointer
Top
The ESP Stack pointer register points to the top of the stack segment.
Base
The EBP Base Pointer general purpose register points to the base of the stack segment