Skip to main content

Instruction format and its types

Short answer

Instruction format is the bit layout with opcode, mode, and address fields. Formats are classified by operand count: three-address (short code, long instruction), two-address (common, e.g. ADD R1,B), one-address (uses accumulator), and zero-address (stack-based, only PUSH/POP have addresses).

What do you mean by instruction format? Explain the different types of instruction formats with example.

An instruction format is the layout of the bits of an instruction, divided into fields. It defines the opcode, the operand addresses and the addressing mode. The size and fields of the instruction depend on the CPU organization.

Fields

  • Opcode: the operation to perform.
  • Mode: how to find the operand.
  • Address field(s): operand or register address (or the operand itself).

Types by number of addresses

1. Three-address format: OPCODE | DEST | SRC1 | SRC2. Example: ADD R1, A, B means R1 = M[A] + M[B]. Short programs, long instructions.

2. Two-address format: OPCODE | DEST/SRC1 | SRC2. Example: ADD R1, B means R1 = R1 + M[B]. The destination is also a source. Most common in commercial machines.

3. One-address format: OPCODE | ADDRESS. The accumulator is the second, implied operand. Example: ADD B means AC = AC + M[B].

4. Zero-address format: OPCODE only. Operands are on the top of a stack. Example: ADD pops two items, adds and pushes the result. PUSH A / POP A need one address.

For X = (A+B)*(C+D):

3-addr: ADD R1,A,B   ADD R2,C,D   MUL X,R1,R2
2-addr: MOV R1,A  ADD R1,B  MOV R2,C  ADD R2,D  MUL R1,R2  MOV X,R1
1-addr: LOAD A  ADD B  STORE T  LOAD C  ADD D  MUL T  STORE X
0-addr: PUSH A PUSH B ADD PUSH C PUSH D ADD MUL POP X

By length

  • Fixed length (RISC): simple decoding, easy pipelining.
  • Variable length (CISC): saves memory but needs more complex decoding.

Other types

  • Register-reference, memory-reference, I/O formats in the basic computer, separated by mode and opcode bits.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Organization and Architecture chapter 2 questions →