Little Man's Mailroom
From Python to machine code, one mailbox at a time
Your mission
A little man runs a mailroom with 100 numbered mailboxes, and a tiny program is waiting in them. Find out how instructions and data sit side by side as 3-digit codes, watch him run the program, change it, then be the assembler who turns LDA, ADD and STO into machine code.
Explore
Tap each part of the mailroom, run the program, and compare the same task at three levels.
Meet the Little Man Computer: a teaching model of how simple machine instructions work together. A little man runs a mailroom. His mailboxes hold a tiny program that adds 7 and 5. Tap each glowing part, or a name below, to find out how it works.
0 of 7 discoveries made
Experiment
Change the numbers and the instructions, run the program step by step, assemble your own code, and try it on a different processor.
An assembler turns each mnemonic into its 3-digit LMC code: the first digit is the operation, the last two are the mailbox. Change any line, then press Assemble.
Tap any line to see its partners at the other two levels.
Mailroom experiments
Try each one. They tick themselves off.
0 of 6 experiments done
Challenge
Six letters to deliver: assemble and decode instructions, trace a program, put it in order and fix a bug.
The Little Man's notes
- 100 mailboxes, 00 to 99
- Code = operation digit + mailbox: 520 = LDA 20
- LDA 5xx · ADD 1xx · SUB 2xx · STO 3xx
- OUT 902 · HLT 000 · DAT holds data
- Machine → assembly → high-level: easier to read
Deliver all 6 letters to finish this stage.
Understand
Here is what the mailroom was showing you, in the words you need for the exam.
Three levels of programming languages
A computer program is a set of instructions written to perform a particular task. An algorithm describes the steps; source code expresses those steps in a programming language. Programs can be written at three levels:
| Feature | Machine | Assembly | High-level |
|---|---|---|---|
| Human readability | Very low | Moderate | Generally high |
| Representation | Encoded machine instructions | Mnemonics and symbols | Abstract statements |
| Hardware dependence | High | High | Usually lower at source level |
| Translation required | No further source translation | Assembler | Compiler or language runtime |
As we move from machine language to high-level language, programs become easier for humans to read and write, but the computer ultimately executes machine instructions.
Machine language
Machine instructions are encoded as binary values. Each instruction specifies an operation (such as add, load or store) and, often, an operand (a register, value or memory address). Each processor architecture defines its own instruction set, and a compatible processor executes them directly.
It is difficult for people: long binary patterns are hard to read, writing them is tedious and error-prone, programs are hard to change, and code for one instruction-set architecture (ISA), such as x86-64, may not run directly on another, such as ARM64.
Assembly language and the assembler
Assembly language represents low-level instructions with mnemonic names, such as LDA, ADD, SUB and STO. Instructions can refer to memory locations or to symbolic labels.
An assembler converts assembly source into machine code: in the LMC, ADD 21 becomes 121, meaning "add the value stored in mailbox 21 to the accumulator".
The Little Man Computer
The LMC uses 100 numbered memory locations (mailboxes 00 to 99). Instructions are written as 3-digit decimal codes, each one performs a simple operation, and programs contain ordered instructions and data. The accumulator holds the value being worked on.
| LMC instruction | Meaning | Code |
|---|---|---|
LDA 20 | Load the value from mailbox 20 into the accumulator | 520 |
ADD 21 | Add the value from mailbox 21 to the accumulator | 121 |
SUB 21 | Subtract the value in mailbox 21 from the accumulator | 221 |
STO 22 | Store the accumulator's value in mailbox 22 | 322 |
OUT | Send the accumulator's value to the output | 902 |
HLT | Stop the program | 000 |
DAT 007 | A mailbox that holds data (here, the number 7) | 007 |
Careful: the LMC is an educational model, not the instruction format of a real CPU.
High-level languages
High-level languages are designed to express instructions in a more human-readable form. The Python program a = 7, b = 5, result = a + b, print(result) does the same job as the eight LMC mailboxes: a single high-level statement may represent multiple lower-level instructions. That makes complex programs easier to develop and maintain. Examples: Python, C++, Java, JavaScript.
Words to know
- Computer program
- A set of instructions written to perform a particular task.
- Source code
- The steps of an algorithm expressed in a programming language.
- Machine language
- Instructions encoded as binary values that a processor executes directly.
- Assembly language
- Low-level instructions written with mnemonic names, such as LDA and ADD.
- Assembler
- Converts assembly source into machine code.
- Operand
- The data an instruction works on, such as a memory address.
- Accumulator
- Holds the value being worked on, and the results of calculations.
- Instruction set (ISA)
- The machine instructions a processor architecture defines, such as x86-64 or ARM64.
Exam tip
Be ready to translate in both directions: LDA 20 ↔ 520, STO 22 ↔ 322. Say what the two parts mean: the first digit is the operation, the last two digits are the mailbox address, and remember that the address is not the value. When comparing the three levels, use the four features: readability, representation, hardware dependence and the translation needed.