Stack Organization &
Addressing Mode
By
Dr. Shivani Agarwal
Formats of writing Languages:-
1. Register Transfer:- copying the content of one register to another
R2 R1
2. Control Function:- Similar to if statement
P: R2 R1
if(P=1) then (R2 R1)
3. Simultaneous Operations:- Two or more operations are occur
P: R2 R1,MAR IR
R1
N
T: Load
Control(T) R2 clock
Register Stack
Insertion Operation
Deletion Operation
• In 64 stack word it is (0-63) SP contains 6 bits it cant
exceed from 6 to 7 or any number so max value is
111111 if its exceed then its 0.
• 111111+1=1000000 ,this exceed 1 represents flag
FULL1 and buffer is 0,this condition represents
STACK OVERFLOW.
• When the buffer is 0 (000000) and it is decremented by
1 so the result is 111111 it is 63 then EMPTY1,
CONDITION OF STACK UNDERFLOW.
Memory Stack
A Portion of computer memory divided in
to 3 segments program, data and stack.
• PC point the address of next instruction
and it is used during the fetch phase to PC
read an instruction
• AR points at an array pointer of data AR
and it is used during the operand fetch SP
and execute an instruction.
• SP points at the value of top of stack. It
is used for insert or del an item into or
from the memory stack.
- A portion
of memory is used as a stack with a
processor register as a stack pointer
- PUSH: SP SP - 1
M[SP] DR
- POP: DR M[SP]
SP SP + 1
- Most computers do not provide hardware to check
stack overflow (full stack) or underflow(empty stack)
Register Stack Memory Stack
It is on the CPU It is on RAM
It is faster than Memory stack It is Slower
It is limited in size It is larger in size
Size is 32 bits to 64 bits Size is GB to TB
REVERSE POLISH NOTATION
• Reverse Polish notation (RPN) is a method for representing expressions in which the operator
symbol is placed after the arguments being operated on. Polish notation, in which the operator
comes before the operands, was invented in the 1920s by the Polish mathematician Jan Lucasiewicz.
• Arithmetic Expressions: A + B
• A+B Infix notation
• +AB Prefix or Polish notation
• AB+ Postfix or reverse Polish notation
Evaluation of Arithmetic Expressions
• Any arithmetic expression can be expressed in parenthesis-free
Polish notation, including reverse Polish notation
Instruction Format