Skip to content
BetterDL

LOAD instruction

Also called: LOAD, load from memory

The instruction that copies a word from memory into the accumulator. In Tiny8, LOAD a does ACC ← M[a] and updates the zero flag.

LOAD a (Tiny8 opcode 1) copies the word at address a into the accumulator: ACC ← M[a]. The memory word is unchanged; the ACC's old value is gone.

Its execute steps:

  • E1 MDR ← M[MAR]: read the operand. The MAR already holds a, from the decode step.
  • E2 ACC ← MDR: copy it into the ACC.

With fetch and decode, that's 6 cycles.

Because the ACC loads, the zero flag loads too: Z = 1 if the loaded word is 0. That makes LOAD useful for testing a value: LOAD it, then JZ.

LOAD is how almost every Tiny8 calculation starts, since ADD and SUB need a value already in the ACC. Its partner, STORE, goes the other way.

Worked example

Example

LOAD a zero

ACC = 5, Z = 0, and M[9] = 00. Tiny8 executes LOAD 9 (19).

  1. 1.

    E1: MDR = 00.

  2. 2.

    E2: ACC = 0, and since the new value is 0, Z = 1.

  3. 3.

    M[9] is still 00. LOAD only reads memory.

Common mistakes

  • Loading the number a instead of the word at address a.

  • Forgetting that LOAD updates Z.

Practice LOAD instruction

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

Learn it step by step

LOAD instruction is taught in Basic CPU / Computer Architecture.