Demonstrate How The Size Of A Machine Program Changes For The Computation Of The Expression Z=(a+b)*(c+d*e) When Different Instruction Sets, Having Zero Address, One Address, Two Address And Three Address Instructions, Are Used
Join Whatsapp Channel for Ignou latest updates JOIN NOW

Demonstrate how the size of a machine program changes for the computation of the expression z=(a+b)*(c+d*e) when different instruction sets, having zero address, one address, two address and three address instructions, are used

To demonstrate how the size of a machine program changes for the computation of the expression ( z=(a+b)(c+de) ) when different instruction sets are used, let’s consider four scenarios: zero address, one address, two address, and three address instructions.

Zero Address Instructions:

In zero address instructions, operands are implicitly specified by the instruction opcode, and results are stored on the top of a stack.

The computation of the expression involves pushing values onto the stack, performing operations, and popping results.

Example code:

PUSH a
PUSH b
ADD
PUSH c
PUSH d
PUSH e
MUL
MUL

One Address Instructions:

In one address instructions, the operand is implicitly taken from the accumulator, and the result is stored back in the accumulator.

The computation involves loading values into the accumulator, performing operations, and storing the result back in the accumulator.

Example code:

LOAD a
ADD b
STORE temp1
LOAD c
LOAD d
MUL
ADD temp1
LOAD e
MUL

Two Address Instructions:

In two address instructions, both operands and the result are explicitly specified in the instruction.

The computation involves specifying both operands and the result in each instruction.

Example code:

ADD z, a, b
MUL temp1, d, e
ADD z, c, temp1
MUL z, z, temp1

Three Address Instructions:

In three address instructions, each instruction specifies one operation with two operands and one result.

The computation involves specifying each operation with two operands and one result.

Example code:

ADD temp1, a, b
MUL temp2, d, e
ADD temp3, c, temp2
MUL z, temp1, temp3

Comparison:

  • Zero Address Instructions: Require fewer instructions but may be less efficient due to stack operations.
  • One Address Instructions: Relatively simple but may require more instructions due to loading and storing.
  • Two Address Instructions: Efficient use of instructions but require specifying all operands explicitly.
  • Three Address Instructions: Similar to two address instructions but more readable and expressive.

The size of the machine program can vary significantly depending on the instruction set architecture and the specific instructions available. Each instruction set has its trade-offs in terms of simplicity, efficiency, and readability.

error: Content is protected !!