Instruction Format:
An instruction format defines the layout of bits of an instruction in terms of constituent parts. There are various instruction format's depending upon the architecture of the computer. The types of commonly used instructions are:
- Three-Address Instruction.
- Two-Address Instruction.
- One-Address Instruction.
- Zero-Address Instruction.
Three-Address Instruction:
A three address instruction consists of the following parts:
- Operation code.
- Addresses of two operands, called address 1 and address 2.
- Address of the memory location where the result of the operation is to be stored i.e., address of the destination.
The number of bits (field length) allocated to each of the three parts depend upon the computer. A typical three address instruction is shown below.
OP code Address 1 Address 2 Address of Destination
A register called program counter (PC) is used to computer the address of the next instruction and the process of the execution of instruction continues.
Two Address Instruction:
In this type of instruction one operand is placed in a specified register such as an accumulator and the address of the next instruction is obtained from another register called program counter (PC). This implies that such an instruction should have the following parts.
- Operation code.
- Address of one of the operands, say address 1.
- Address of the storage location where the result is to be stored. This address is denoted by address 2.
The general form of a two address instruction is
OP code Address 1 Address 2
One Address Instruction:
As the name suggests, this instruction has address of one operand only, the other operand is stored in accumulator. The result of operation are left in the accumulator it self, from where these can be moved to main memory by another instruction. The address of the next instruction is obtained from the program counter. The general form of a one-address instruction is
OP code Address 1
No doubt with one address instruction more bits of the instruction word could be allocated to OP code and the address of the operand.
Zero Address Instruction:
The zero address instructions are also called stack instructions and consist of OP code only. The address of operand and destination are implied. The general form of zero address instruction is.
OP code