Login

Please fill in your details to login.





cpu simulator

Interactive online CPU simulator widget.
A visual simulator for the Fetch-Decode-Execute cycle. It allows students to write simple programs using a reduced instruction set (see below) and watch how the CPU processes them step-by-step.


How to Use


Load the instructions into the RAM/Memory using the drop-down list.
If the instruction requires an operand value, the operand spinner will activate.
To clear an instruction, click the 'x'.
Click the Run button for automatic execution.
Click the Step button to control the execution.
Click the Reset button to reset the simulator to it's original state.

The simulation will run through the Fetch-Decode-Execute cycle repeatedly until it fetches, decodes and executes a
HALT
instruction. The blue information panel will describe the CPUs task and the Output Console will show any output from the OUT instruction. If the program uses the INP instruction, a modal window will appear for your input. Watch the Program Counter (PC), the Current Instruction Register (CIR) and the Accumulator (ACC) as the CPU cycles.

Instruction Set


Command
Description
Example
LOAD
Loads a value from a specific memory address into the Accumulator.
LOAD 5
ADD
Adds the value at a specific memory address to the value in the Accumulator.
ADD 6
SUB
Subtracts the value at a specific memory address from the value in the Accumulator.
SUB 6
STORE
Stores the current value of the Accumulator into a specific memory address.
STORE 5
INPUT
Pauses the program and asks the user to enter a number. The number is stored in the Accumulator.
INPUT
OUT
Outputs the current value of the Accumulator to the console.
OUT
HALT
Stops the program execution immediately.
HALT
JUMP
Unconditionally jumps to a specific memory address (changes the Program Counter).
JUMP 0
IF ZERO
Jumps to a specific memory address ONLY if the value in the Accumulator is 0.
IF ZERO 4

Sample Programs to try


1
Add Two Inputs

Asks the user for two numbers, adds them, and outputs the result.

INPUT; STORE 10; INPUT; ADD 10; OUT; HALT


2
Subtract Two Inputs

Asks for two numbers, subtracts the second from the first.

INPUT; STORE 10; INPUT; STORE 11; LOAD 10; SUB 11; OUT; HALT


3
Countdown from 5

Counts down from 5 to 1 using a loop.

LOAD 10; OUT; SUB 11; STORE 10; IF ZERO 6; JUMP 1; HALT; 0; 0; 0; 5; 1


4
Double a Number

Takes an input and multiplies it by 2.

INPUT; STORE 10; ADD 10; OUT; HALT


5
Multiply by 3

Takes an input and multiplies it by 3 using repeated addition.

INPUT; STORE 10; ADD 10; ADD 10; OUT; HALT


6
Infinite Counter

Counts up from 0 indefinitely (Run at high speed).

LOAD 10; ADD 11; STORE 10; OUT; JUMP 1; 0; 0; 0; 0; 0; 0; 1


7
Logical Check (Is Zero?)

Outputs 1 (True) if input is 0, otherwise 0 (False).

INPUT; IF ZERO 4; LOAD 10; JUMP 5; LOAD 11; OUT; HALT; 0; 0; 0; 0; 1


8
Equality Checker

Inputs two numbers. Outputs 1 if they are equal, 0 if not.

INPUT; STORE 9; INPUT; SUB 9; IF ZERO 7; LOAD 10; JUMP 8; LOAD 11; OUT; 0; 0; 1


9
Swap Two Values

Swaps values in memory locations 10 and 11 using slot 9 as temp.

LOAD 10; STORE 9; LOAD 11; STORE 10; LOAD 9; STORE 11; HALT; 0; 0; 0; 5; 8


10
Input Accumulator

Keeps asking for input and adding it to a total until you enter 0.

LOAD 10; INPUT; IF ZERO 6; ADD 10; STORE 10; JUMP 1; LOAD 10; OUT; HALT; 0; 0

Last modified: February 6th, 2026
The Computing Café works best in landscape mode.
Rotate your device.
Dismiss Warning