Zero Address Instructions

Stack-organized computers use zero address instructions. Zero address instructions have no OPERAND with OPCODE.

Note: in expression a+b, + is operand and a,b are the OPCODE

Stack-organized computers follow the Last in First out (LIFO) rule, where operations are always performed at the top of the stack value.

  • The PUSH command helps to push/add data into the stack.
  • The POP command is used to pop/remove the data from the stack.
  • RAM or Registers are required to implement stack organization.

Advantages of Zero address instructions

Let’s see some advantages of zero address instructions

  • There is no need for an operand, that’s why these instructions are very simple.
  • Execution is speedy because it minimizes the overhead of operand fetching and decoding.
  • They also contain very little memory space.

Disadvantages of Zero address instructions

Let’s see some disadvantages of zero address instructions

  • Limited Expressiveness for complex expressions
  • Although zero-address instructions save space, but it is very difficult for memory management, especially in systems where memory allocation and de-allocation are important.
  • Highly dependent on the Stack, overflow in the stack may leads toward problems.
  • Limited compatibility with all computing architectures.

Examples of Zero Address Instructions

In this section, we will see various examples of zero address instructions in detail.

Example 01:

Write a program for zero address instructions to evaluate the following arithmetic instruction

X= {(a*b) + (c*d)}

Zero Address instruction example 01

Postfix Notation: ab*cd*+

Let see the further explanation of Example 01 using the following expression

(3*4) + (5*6)

Zero Address stack implementation

Postfix Notation: 34*56*+

Example 02:

Write a program for zero address instructions to evaluate the following arithmetic instruction

X= {(a-b)+c*(d*e-f)} / {(g+h*k)}

Zero Address instruction example 02

Postfix Notation: ab-cde*f-*+ghk*+/

Example 03:

Write a program for zero address instructions to evaluate the following arithmetic instruction

{(a-b)} / {(c)+(d*e)}

Zero Address instruction example 03

Postfix Notation: ab-cde *+/

Remember:

  • Always use the minimum number of instructions (so that the program length can be minimized).
  • Always use the minimum number of registers (Register can be reused).