Write assembly, assemble it into numeric mailboxes, and run it through the fetch-decode-execute cycle one instruction at a time.
The Little Man Computer is a tiny model of a real CPU, designed for teaching. Imagine a single person (the “little man”) sitting in a room with 100 numbered mailboxes, a small calculator (the accumulator), a finger pointing at the next mailbox to read (the program counter), an in-tray (input), and an out-tray (output). That’s the whole machine.
000–999). Some mailboxes hold instructions; some hold data.OUT instruction lands here.Every LMC instruction is a 3-digit number. The first digit is the opcode (what to do); the last two digits are the operand (which mailbox to use).
Example: ADD 5 becomes the number 105 — opcode 1 (ADD), operand 05. The Assemble button does this conversion: it reads your assembly text and fills the mailboxes with the right numbers.
Every instruction goes through the same three steps. Click Step once and you'll run one full cycle:
LDA addr → ACC = mailbox[addr] (the cyan-flash on the memory grid shows which mailbox was touched).STA addr → mailbox[addr] = ACC.ADD addr → ACC = ACC + mailbox[addr].SUB addr → ACC = ACC − mailbox[addr].BRA addr → jump: PC = addr.BRZ addr → jump only if ACC is zero.BRP addr → jump only if ACC is positive (≥ 0).INP → take the next number from the Inputs box, put it in ACC.OUT → copy ACC into the OUTPUT list.HLT → stop.Then the cycle repeats with the new PC. The machine keeps running until it hits a HLT.
| Mnemonic | Code | What it does |
|---|---|---|
| INP | 901 | take the next input into ACC |
| OUT | 902 | send ACC to OUTPUT |
| LDA xx | 5xx | load mailbox[xx] into ACC |
| STA xx | 3xx | store ACC into mailbox[xx] |
| ADD xx | 1xx | ACC = ACC + mailbox[xx] |
| SUB xx | 2xx | ACC = ACC − mailbox[xx] |
| BRA xx | 6xx | unconditional jump to xx |
| BRZ xx | 7xx | jump to xx if ACC = 0 |
| BRP xx | 8xx | jump to xx if ACC ≥ 0 |
| HLT | 000 | stop |
| DAT n | nnn | declare a data slot (optional initial value) |
Labels are nicknames you give to a mailbox address. When the assembler sees loop LDA n, it remembers “the address of that instruction is called loop” — so any later BRA loop is automatically turned into the correct mailbox number. Labels save you from having to count addresses by hand.
Every program — in any language — is built from three patterns. LMC shows them in their rawest form:
BRZ and BRP let the program take different paths based on what's in ACC. The Max of two example computes b − a, then BRP jumps to one branch if the result is ≥ 0 and falls through to the other branch if it's negative.BRA jumps backwards to repeat a block of instructions. Combined with a counter that's decremented each loop and a BRZ exit test, you get a while/for loop. The Countdown and Multiply examples are loops.Suppose the PC is 3, mailbox[3] holds 101 (ADD 1), mailbox[1] holds 7, and ACC is 5.
101. INSTRUCTION = ADD 1. PC becomes 4.1xx means ADD; operand is 01.7. ACC = 5 + 7 = 12.Then the cycle starts again with PC = 4. Press Step on the simulator and watch the orange PC arrow move, the ACC change, and the mailbox you read flash cyan.