Stack Organization
Stack Organization
Overview
Introduction
Stack Organization
Instruction Formats
Addressing Modes
Stack Organization
Stack
Very useful feature for nested subroutines, nested
interrupt services
Also efficient for arithmetic expression evaluation
Storage which can be accessed in LIFO
Pointer: SP
Only PUSH and POP operations are applicable
Stack Organization
Register Stack Organization
Memory Stack Organization
63
Flags
FULL EMPTY
Stack pointer 4
SP C 3
6 bits B 2
A 1
Push, Pop operations 0
DR
/* Initially, SP = 0, EMPTY = 1, FULL = 0 */
PUSH POP
SP SP + 1 DR M[SP]
M[SP] DR SP SP 1
If (SP = 0) then (FULL 1) If (SP = 0) then (EMPTY 1)
EMPTY 0 FULL 0
SP 3000
stack
3997
3998
3999
4000
4001
- A portion of memory is used as a
stack with a
processor register as a stack
pointer
- PUSH: SP SP - 1
M[SP] DR
- -Most
POP:DR M[SP]
computers do not provide hardware to check stack
SP SP + 1
overflow (full
stack) or underflow (empty stack) must be done in
CSE 211, Computer Organization and Architecture Harjeet Kaur,
Central Processing Unit 5 Lecture 23
6
4 5 5 30
3 3 12 12 12 12 42
3 4 * 5 6 * +
Processor Organization
In general, most processors are organized
in one of 3 ways
Stack organization
All operations are done using the hardware stack
For example, an OR instruction will pop the two top
elements from the stack, do a logical OR on them,
CSE 211, Computer Organization
and push andon
the result Architecture
the stack Harjeet Kaur,