Stack Organization
Stack: A storage device that stores
information in such a manner that the item
stored last is the first item retrieved.
Also called last-in first-out (LIFO) list.
Useful for compound arithmetic operations
and nested subroutine calls.
Stack Organization
Stack pointer (SP): A register that holds
the address of the top item in the stack.
SP always points at the top item in the
stack
Stack Operations : The two operations are
• Push: Operation of insertion or to insert an
item into the stack.
• Pop: Operation of deletion or to retrieve an
item from the stack.
IMPLEMENTATION OF STACK
In computer, stack can be implemented in
two ways –
Register Stack
Memory Stack
REGISTER STACK
• A stack can be
organized as a
collection of a finite
number of registers
that are used to
store temporary
information.
REGISTER STACK
• In a 64-word stack, the
stack pointer contains 6 bits.
• The one-bit FULL register
is set to 1 when the stack is
full;
EMPTY register is 1 when
the stack is empty.
• The data register holds the
data to be written into or
read from the stack.
MEMORY STACK
A stack can be implemented in a RAM attached
to a CPU. The implementation of a stack in the
CPU is done by assigning a portion of memory
to a stack operation and using a processor
register as a stack pointer. The starting
memory location of the stack is specified by
the processor register as a stack pointer.