2025 26 2d

Computer Organization and Architecture2025-267 marksInstruction types, formats, instruction cycles and sub cycle

Explain different types of instructions. Explain various instruction formats with suitable examples.

Explain different types of instructions. Explain various instruction formats with suitable examples.

Quick answer

An instruction tells the CPU one operation. By their job, instructions fall into these groups.

Types of instructions

  • Data transfer: move data between registers and memory, for example LOAD, STORE, MOV, PUSH, POP.
  • Arithmetic: ADD, SUB, MUL, DIV, INC, DEC.
  • Logical and shift: AND, OR, XOR, NOT, shifts and rotates.
  • Program control: JMP, conditional branches such as JZ, CALL and RET. They change the value of PC.
  • Input and output: IN and OUT, which move data to and from devices.

Instruction formats

An instruction word has an opcode, which tells the operation, and operand fields, which tell where the data is. It may also have a mode field for the addressing mode. The number of address fields decides the format.

Take the statement $X = (A + B) \times (C + D)$ to see each format.

Three-address format. Each instruction has two sources and one destination.

ADD R1, A, B      ; R1 = A + B
ADD R2, C, D      ; R2 = C + D
MUL X, R1, R2     ; X = R1 * R2

The program is short, but the instructions are long.

Two-address format. The first operand is also the destination.

MOV R1, A
ADD R1, B
MOV R2, C
ADD R2, D
MUL R1, R2
MOV X, R1

This is the common format in x86 processors.

One-address format. The accumulator AC is the second operand and the destination.

LOAD A
ADD B
STORE T
LOAD C
ADD D
MUL T
STORE X

Zero-address format. Operands are taken from the top of a stack, so the instruction names no address. Only PUSH and POP name a memory address.

PUSH A
PUSH B
ADD
PUSH C
PUSH D
ADD
MUL
POP X

The programs use 3, 6, 7 and 8 instructions. More address fields mean fewer instructions, but longer ones. A zero-address instruction is the shortest, but it needs more of them.

Choosing a format. The three-address format is used in RISC machines such as MIPS, where registers hold the operands, so the fields are short. The two-address format is common in CISC machines such as x86. The one-address format was used in early machines with a single accumulator. The zero-address format is used in stack machines, for example in the evaluation of expressions and in the Java virtual machine. The choice is a balance between program length, instruction length and speed.

Instruction length. For example, if the opcode is 8 bits and each register field is 5 bits, a three-register instruction needs $8 + 3 \times 5 = 23$ bits, and it fits in a 32 bit word with room for a mode field.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.

Up nextExplain the concept of RISC architecture. Discuss its features and advantages. Compare RIS