Little Man Computer Simulation
Ready
Input:
Output:
Run at Medium speed - about 0.5 seconds per cycle
Select an example to load:
The Code Editor is based on a grid system, with columns for you to enter labels, operators and operands. The left-most column is used to show which line of code is being executed when the program is running, and the 'Line' column shows non-editable line numbers.
You can move between lines and columns by pressing the Tab key, or by using the cursor keys.
Ctrl-Z and Ctrl-Y will undo and redo the last edit, but only if you are not editing a cell in the Code Editor.
Select a line by left-clicking anywhere on the line. The line will be highlighted.
You can delete the current line using the Del or Delete key - all of the subsequent lines will be moved up.
Pressing the Ins or Insert key will create a new line above the current line, moving all subsequent lines down.
When you are happy with your code, press the Assemble button, and the LMC Simulator will check and assemble your code into memory. If there are any errors, a message will appear in the Console window indicating the line and problem.
The Load button can be used to load pre-written programs from your computer.
The Save button will save a text file on your computer containing the current program.
The Print button will create and download a PDF version of the current program.
The Little Man Computer (LMC) is a simplified model of a computer, based on the von Neumann architecture.
This web app provides a simulation of the LMC, so that you can write programs in the LMC assembler and then assemble and run the programs. The simulator will show you the state of all of the main registers in the CPU, as well as the state of the 'memory' of the LMC.
The flow of data around the CPU is displayed, and you can pause and resume the execution of your program at any time.
The code editor has individual columns for labels, operators and operands. To learn more about how the editor works, just press the 'Help' button below the code window. You can use Ctrl-Z to undo any editor actions.
There are a number of example programs that you can try out - just press the 'Examples' button below for more information.
Instruction | Mnemonic | Machine Code | Explanation |
---|---|---|---|
Load Accumulator | LDA | 5xx | Load the contents of the given memory address (xx) into the Accumulator |
Store Accumulator | STA | 3xx | Store the contents of the Accumulator at the given memory address (xx) |
Add | ADD | 1xx | Add the contents of the given memory address (xx) to the value in the Accumulator |
Subtract | SUB | 2xx | Subtract the contents of the given memory address (xx) from the value in the Accumulator |
Input | INP | 901 | Copy the value from the Input 'mailbox' into the Accumulator |
Output | OUT | 902 | Copy the value from the Accumulator into the Output 'mailbox' |
Branch | BRA | 6xx | Branch (jump) to the instruction at the given memory address (xx) |
Branch if positive | BRP | 8xx | If the value in the Accumulator is positive (including zero), then branch to the instruction at the given memory address (xx) |
Branch if zero | BRZ | 7xx | If the value in the Accumulator is zero, then branch to the instruction at the given memory address (xx) |
Halt | HLT | 000 | Stop execution of the program |
Data | DAT | value of the data | Indicates that the current memory address holds a data value |