Skip to content
BetterDL

Execute step

Also called: execute, execute phase, execution step

The part of the instruction cycle where the CPU carries out what the decoded instruction asks for, such as reading an operand or loading the PC.

After fetch and decode, the execute step does the actual work. It's the only part of the fetch decode execute cycle that differs between instructions.

In Tiny8, execute takes one or two clock cycles:

  • LOAD: E1 MDR ← M[MAR]; E2 ACC ← MDR.
  • ADD: E1 MDR ← M[MAR]; E2 ACC ← ACC + MDR.
  • SUB: E1 MDR ← M[MAR]; E2 ACC ← ACC − MDR.
  • STORE: E1 MDR ← ACC; E2 M[MAR] ← MDR.
  • JMP: E1 PC ← IR[3:0].
  • JZ: E1 if Z = 1 then PC ← IR[3:0].
  • HALT: E1 stop.

Why do memory instructions need two steps? The operand isn't inside the CPU until E1's edge loads it into the MDR, so it can't reach the ACC in the same cycle. Likewise STORE must first move the ACC into the MDR before memory can be written.

So LOAD, STORE, ADD and SUB take 6 cycles in total; JMP, JZ and HALT take 5.

Worked example

Example

Executing SUB B

ACC = 12 and M[B] = 20. Decode has put B in the MAR.

  1. 1.

    E1: MDR = 20 (14).

  2. 2.

    E2: ACC = 12 − 20 = −8, which wraps to 256 − 8 = 248 (F8).

  3. 3.

    Z = 0, because 248 isn't zero.

Common mistakes

  • Doing E1 and E2 in one cycle. Each register transfer takes effect only at its clock edge.

  • Forgetting that a not-taken JZ still spends its E1 cycle.

Practice Execute step

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

Learn it step by step

Execute step is taught in Basic CPU / Computer Architecture.