Skip to content
BetterDL

Instruction decoding

Also called: decode, decode step, decoding an instruction, instruction decode

Working out what an instruction asks for by splitting its bits into fields and identifying the opcode, by hand or with a decoder.

Instruction decoding means turning an instruction's bits back into meaning. It happens in two places.

By hand, when you read a program listing. For Tiny8:

  1. Split the 8-bit word into two nibbles (two hex digits).
  2. The high nibble is the opcode: look it up.
  3. The low nibble is the address.

So 5A = opcode 5 (JMP), address A: JMP A.

In hardware, in the decode step D of the fetch decode execute cycle. The opcode bits IR[7:4] feed a 4-to-16 decoder, which raises exactly one output line, the one for that instruction. The control unit uses those lines to choose the execute steps. Tiny8's D step also does MAR ← IR[3:0], so the operand address is ready in case the instruction needs memory.

Decoding itself needs no control signal. The decoder is combinational, so its outputs simply follow the IR. They only change after the IR loads at the end of F3.

Worked example

Example

Decoding by hand

Decode 0110 1010 and 2C.

  1. 1.

    0110 1010: opcode 0110 = 6 = JZ, address 1010 = A. It's JZ A.

  2. 2.

    2C: opcode 2 = STORE, address C. It's STORE C.

  3. 3.

    Neither word says anything about data values: STORE C writes the ACC to address C, whatever is there.

Common mistakes

  • Reading the address as the value used. LOAD 9 uses the word at address 9.

  • Swapping nibbles. 53 is JMP 3; 35 is ADD 5.

  • Expecting the decoder to show the new opcode during F1 and F2. The IR still holds the previous instruction.

Practice Instruction decoding

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Instruction decoding is taught in Basic CPU / Computer Architecture.