Skip to content
BetterDL

Jump instruction

Also called: JMP, unconditional jump, branch instruction, unconditional branch

An instruction that loads the program counter with a new address, so the next instruction comes from somewhere other than the next word.

Normally the CPU runs instructions in address order, because fetch adds 1 to the program counter. A jump breaks that order: it loads the PC with a new address, so the next fetch comes from there.

Tiny8 has two:

  • JMP a (opcode 5): always PC ← a. An unconditional jump.
  • JZ a (opcode 6): PC ← a only if Z = 1. A conditional branch.

Jumps are how programs get structure:

  • a backward jump repeats code, making a program loop;
  • a forward jump skips code;
  • a conditional jump chooses between two paths, like an if-statement.

In hardware, JMP's execute step is one transfer, E1 PC ← IR[3:0]: the PC's mux selects the IR's address field and LdPC = 1. So JMP takes 5 cycles. It doesn't touch the ACC or Z.

Worked example

Example

Skipping an instruction

Tiny8 runs from PC = 0, with M[D] = 7: 0: LOAD D (1D), 1: JMP 3 (53), 2: ADD D (3D), 3: STORE E (2E), 4: HALT (00).

  1. 1.

    LOAD D: ACC = 7, PC = 1.

  2. 2.

    JMP 3: PC = 3. The ADD at address 2 is skipped.

  3. 3.

    STORE E: M[E] = 7, PC = 4.

  4. 4.

    HALT. M[E] ends at 7, not 14.

Common mistakes

  • Adding 1 to the jump target. After JMP 3, the next fetch is from address 3 itself.

  • Thinking JMP changes Z or the ACC. It changes only the PC.

Practice Jump instruction

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

Learn it step by step

Jump instruction is taught in Basic CPU / Computer Architecture.