Skip to content
Pete Dring edited this page Mar 9, 2015 · 3 revisions

image

The Little Man Computer CPU has 3 registers:

Program Counter Register

This stores the memory address of the next instruction that the CPU should run. It starts at 0 and increases by one each time an instruction is run, unless that instruction tells it to jump to another location.

Instruction Register

This stores a copy of the value in memory at the address stored in the program counter register. This instruction is what tells the CPU what to do.

Accumulator Register

This is where the CPU stores the result of any instruction such as the data read from an input device or the result of an addition or subtraction.

Fetch / Execute Cycle

The CPU works by following 3 steps:

  1. Fetch: The CPU reads the value of the Program Counter register to find out where in memory the next instruction should be read from. The Instruction register is set to whatever value is stored at that address in memory.
  2. Decode: The first digit of the instruction register determines what operation the CPU will perform. These values are best explained by the table that you see if you press the help button by the code editor:
  3. Execute: The CPU runs (executes) the current instruction, saves the result into the accumulator register and increases the program counter by one to point to the next instruction (unless it's been told to jump to another memory location)

image