CPU-Stack organization
CPU-Stack organization
A stack is an ordered linear list in which all insertions and deletions are made
at one end, called top. It uses Last In First Ou t (LIFO) access method which is
the most popular access method in most of the C P U s .
A register is used to store the address of the topmost element of the stack
which is known as Stack Pointer(SP) because its value always points at the top
item in the stack.
The main two operations that are performed on the operands of the stack are
Push and Pop. These two operations are performed from one end only.
Push Operation: The operation of inserting an item onto a stack is
called push operation.
Pop Operation: The operation of deleting an item onto a stack is called
pop operation.
Applications:
There are two types of stack organization which are used in the computer
hardware:
Register stack:
As shown in fig 2, there are 64 registers used to make a register stack. The
numbers 0,1,2,3,…..upto 63 denote the address of different registers.
S P is a pointer which points to the top of the stack i.e. it currently points
to the item at the top.
The two more registers called F LAG and EMPTY are used. These are
made up of flip-flops. It indicates whether the stack is full or not.
o If FULL = 1, then EMPTY = 0 stack is full.
o If FULL= 0, then EMPTY =1 stack is empty.
D R is the data register through which data is transferred to and from the
stack.
Zero address instructions are used in registers stack organization i.e. the
address that does not contain the address of the operands.
In 64-word stack, the stack pointer contains 6 bits because 2 6 =64.
Since, S P has only 6 bits, it cannot exceed a number greater than 63(111111 in
binary). When 63 is incremented by 1 the result is 0 since 111111+1=1000000,
but S P can accommodate only the six least significant bits S P points to
000000 address register which implies stack is full.
A new item is deleted from the stack if the stack is not empty (if EMTY=0).
The POP operation consists of following sequence of microoperations:
Data register is used to store data. Data is pointed by the address pointer or
register. Program Counter (PC) is used to point the program instruction.
As shown in the diagram, the initial value of S P is 4001 and the stack grows
with decreasing addresses.
follows: SP S P - 1
M[SP] D R
DRM[SP]
SPSP + 1