Open In App

Stack based CPU Organization

Last Updated : 01 Feb, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Based on the number of address fields, CPU organization is of three types: Single Accumulator organization, register based organization and stack based CPU organization.

Stack-Based CPU Organization

The computers which use Stack-based CPU Organization are based on a data structure called a stack. The stack is a list of data words. It uses the Last In First Out (LIFO) access method which is the most popular access method in most of the CPU. A register is used to store the address of the topmost element of the stack which is known as Stack pointer (SP). In this organization, ALU operations are performed on stack data. It means both the operands are always required on the stack. After manipulation, the result is placed in the stack. 

The main two operations that are performed on the operators of the stack are Push and Pop. These two operations are performed from one end only. 

1. Push

This operation results in inserting one operand at the top of the stack and it increases the stack pointer register. The format of the PUSH instruction is: 

PUSH 

It inserts the data word at a specified address to the top of the stack. It can be implemented as: 

// Increment SP by 1
SP <-- SP + 1

//store the content of specified memory address
//into SP; i.e, at top of stack
SP <-- (memory address)

2. Pop

This operation results in deleting one operand from the top of the stack and decreasing the stack pointer register. The format of the POP instruction is: 

POP 

It deletes the data word at the top of the stack to the specified address. It can be implemented as: 

//transfer the content of  SP (i.e, at top most data) 
//into specified memory location
(memory address) <-- SP

//Decrement SP by 1
SP <-- SP - 1

Operation type instruction does not need the address field in this CPU organization. This is because the operation is performed on the two operands that are on the top of the stack. For example: 

SUB 

This instruction contains the opcode only with no address field. It pops the two top data from the stack, subtracting the data, and pushing the result into the stack at the top. 

PDP-11, Intel’s 8085, and HP 3000 are some examples of stack-organized computers.

Stack-Based vs. Register-Based CPU Organization

Aspect Stack-Based CPU Register-Based CPU
Data Storage Uses a stack Uses registers
Instruction Set Simple Complex
Performance Efficient for recursion Faster for random access
Flexibility Limited to stack operations Highly adaptable
Examples JVM ARM processors
Best Use Cases Recursive functions, expressions. General-purpose computing

Advantages of Stack-based CPU organization

  • Efficient computation of complex arithmetic expressions. 
  • Execution of instructions is fast because operand data are stored in consecutive memory locations. 
  • The length of instruction is short as they do not have an address field. 

Disadvantages of Stack-based CPU organization  

  • It is restricted to stack-based operations which makes it less adaptable.
  • It is difficult to coordinate stacks efficiently in parallel processing.

Applications of Stack-Based CPU Organization

  • Virtual Machines: Many modern virtual machines, like the Java Virtual Machine (JVM), use stack-based architectures to simplify execution.
  • Embedded Systems: Suitable for small-scale systems where hardware simplicity and space efficiency are critical.

Note: Stack-based CPU organization uses zero address instruction.


Next Article
Practice Tags :

Similar Reads