Tools · GCSE & A Level

Little Man Computer (LMC) Simulator

Write LMC assembly programs, assemble them, and step through execution one instruction at a time. Watch the accumulator, program counter and all 100 mailboxes update as the fetch-decode-execute cycle runs. Free, no account needed.

LMC Assembly // for comments  ·  LABEL before instruction
Accumulator
000
Program Counter
00
Output

Output will appear here when OUT is executed

Memory (100 mailboxes)
0
000
1
000
2
000
3
000
4
000
5
000
6
000
7
000
8
000
9
000
10
000
11
000
12
000
13
000
14
000
15
000
16
000
17
000
18
000
19
000
20
000
21
000
22
000
23
000
24
000
25
000
26
000
27
000
28
000
29
000
30
000
31
000
32
000
33
000
34
000
35
000
36
000
37
000
38
000
39
000
40
000
41
000
42
000
43
000
44
000
45
000
46
000
47
000
48
000
49
000
50
000
51
000
52
000
53
000
54
000
55
000
56
000
57
000
58
000
59
000
60
000
61
000
62
000
63
000
64
000
65
000
66
000
67
000
68
000
69
000
70
000
71
000
72
000
73
000
74
000
75
000
76
000
77
000
78
000
79
000
80
000
81
000
82
000
83
000
84
000
85
000
86
000
87
000
88
000
89
000
90
000
91
000
92
000
93
000
94
000
95
000
96
000
97
000
98
000
99
000
Instruction set
INP Input → ACC
OUT ACC → Output
HLT Stop
ADD xx ACC + mem[xx]
SUB xx ACC − mem[xx]
STA xx ACC → mem[xx]
LDA xx mem[xx] → ACC
BRA xx Jump to xx
BRZ xx Jump if ACC=0
BRP xx Jump if ACC≥0
DAT n Define data n

What is the Little Man Computer?

The Little Man Computer is a deliberately tiny model of a von Neumann machine, designed in 1965 to make processor execution visible. The metaphor is a little man in a room containing 100 numbered mailboxes, a calculator (the accumulator), and a counter telling him which mailbox to read next.

It matters because it strips the CPU back to something you can hold in your head. The fetch-decode-execute cycle stops being three words to memorise and becomes something you can watch happen, one instruction at a time.

The LMC instruction set

Every instruction is three digits. The first digit is the opcode; the remaining two are the mailbox address it operates on. Opcode 4 is unused.

CodeMnemonicWhat it does
1xxADDAdd the contents of mailbox xx to the accumulator.
2xxSUBSubtract the contents of mailbox xx from the accumulator.
3xxSTAStore the accumulator into mailbox xx. Overwrites what was there.
5xxLDALoad the contents of mailbox xx into the accumulator.
6xxBRABranch always — jump to mailbox xx unconditionally.
7xxBRZBranch if zero — jump to xx only if the accumulator is exactly 0.
8xxBRPBranch if positive — jump to xx if the accumulator is zero or greater.
901INPRead a value from the input into the accumulator.
902OUTOutput the value currently in the accumulator.
000HLTHalt — stop the program.
DATNot an instruction: reserves a mailbox to hold data, optionally with a starting value.

Mistakes I see most often as an examiner

The same errors cost marks year after year on this topic, and every one of them is avoidable once you have seen it.

  • Assuming BRP means "greater than zero". It does not. Zero counts as positive, so BRP branches when the accumulator is zero or greater. This single misunderstanding breaks more student loops than anything else.
  • Forgetting the DAT declarations. Every variable your program stores into needs a mailbox reserved with DAT. Without it the program will not assemble, and in a written answer it loses marks.
  • Getting LDA and STA the wrong way round. LDA loads from a mailbox into the accumulator; STA stores the accumulator into a mailbox. When you are working quickly under exam pressure these invert easily.
  • Omitting HLT. Without it, execution runs past the end of your program into whatever follows and behaves unpredictably.
  • Treating ADD as taking a literal value. ADD 5 does not add five. It adds the contents of mailbox 5. To add a constant you must first store that constant in a mailbox with DAT.

How to answer LMC exam questions

Questions usually take one of three forms: trace this program and state the output, write a program to do X, or explain what this program does. For tracing, build a table with a column for the accumulator, one for each data mailbox, and one for output — then fill in a row per instruction executed. It is slower than tracking it in your head, and it is why students who use a table score better.

For writing programs, start from the structure rather than the instructions: get the input, do the comparison, branch, produce the output, halt. Fill in the mnemonics afterwards.

Frequently asked questions

What is the Little Man Computer?

The Little Man Computer (LMC) is a simplified model of a von Neumann computer, created by Stuart Madnick in 1965 to teach how processors actually execute instructions. It has 100 numbered mailboxes for storage, a single accumulator, a program counter, and a small instruction set. Because it is deliberately tiny, it lets you see the fetch-decode-execute cycle happening without the complexity of a real CPU.

What are the LMC instructions?

The standard set is ADD (1xx), SUB (2xx), STA (3xx), LDA (5xx), BRA (6xx), BRZ (7xx), BRP (8xx), INP (901), OUT (902) and HLT (000), plus DAT to reserve a mailbox for data. Opcode 4 is unused. Each instruction is three digits: the first is the opcode, the remaining two are the mailbox address.

Does BRP branch on zero?

Yes — and this catches students out constantly. BRP means "branch if positive", but in the Little Man Computer zero counts as positive, so BRP jumps when the accumulator is zero or greater. If you need to branch only on a value strictly greater than zero, you have to subtract one first or combine BRP with BRZ.

What is the difference between LDA and STA?

They move data in opposite directions. LDA loads a copy from a mailbox into the accumulator, leaving the mailbox unchanged. STA stores the accumulator into a mailbox, overwriting whatever that mailbox held. The accumulator keeps its value after STA.

Which exam boards use the Little Man Computer?

LMC appears most prominently in OCR GCSE Computer Science J277 and is widely used at A Level and in Key Stage 3 to introduce low-level programming and the fetch-decode-execute cycle. Even where it is not named in your specification, it is an effective way to understand assembly language and how the CPU actually works.