Little Man Computer (LMC) Guide: Architecture & Assembly
Learn computer science fundamentals with this guide to the Little Man Computer (LMC), covering Von Neumann architecture, instruction sets, and assembly.
Little Man Computer (LMC)
A Beginner's Guide to Computer Architecture & Assembly Programming
Computer Science Fundamentals
What We'll Cover
A step-by-step journey through the architecture, instruction set, and programming of the LMC.
What is the Little Man Computer?
LMC Architecture Overview
The Instruction Set
Memory & Registers
How Programs Execute
Writing LMC Assembly Programs
Example Programs (Add, Subtract, Loops, Conditionals)
LMC vs Real CPUs
What is the Little Man Computer?
Educational Model
Created by Dr. Stuart Madnick in 1965 as a simplified model to teach computer architecture.
Fundamental Concepts
Designed to teach how CPUs work at a foundational level with a simple assembly-like instruction set.
Von Neumann Architecture
It accurately models real computer architecture in an accessible, simple way.
The βLittle Manβ Metaphor
Imagine a tiny man inside the computer fetching, reading, and executing instructions.
Computer Science Fundamentals
LMC Architecture Overview
A conceptual diagram of the Little Man Computer's key components and data flow.
Computer Architecture Fundamentals
Memory & Registers
Memory (Mailboxes)
100 mailboxes numbered 00β99
Each stores a 3-digit number (000β999)
Holds both instructions AND data
Addressed by a 2-digit number
Registers
Accumulator (ACC)
Main working register, stores results
Program Counter (PC)
Points to the next instruction address
Instruction Register (IR)
Holds the currently executing instruction
901
399
042
911
The LMC Instruction Set
Mnemonic
Opcode
Description
The Fetch-Decode-Execute Cycle
A step-by-step deep dive into how the Little Man Computer processes instructions.
FETCH
The Little Man looks at the Program Counter, goes to that mailbox, and picks up the instruction. PC increments by 1.
DECODE
The instruction is placed in the Instruction Register. The Little Man figures out what to do (which operation and which address).
EXECUTE
The Little Man carries out the instruction (e.g., adds a number, stores a value, jumps to a new address).
This cycle repeats until a HLT instruction is reached.
Computer Architecture β’ Instruction Cycle
Writing LMC Programs β The Basics
Programs are written as a list of mnemonics (one per line)
Labels can be used to name memory addresses (e.g., NUM DAT 5)
Instructions are assembled into 3-digit opcodes in memory
Programs start executing from address 00
Always end with HLT
Computer Science Fundamentals
Example 1: Add Two Numbers
LMC Program Code
INP STA FIRST INP ADD FIRST OUT HLT FIRST DAT
Input: 5, 3 β Output: 8
Example 2: Subtract Two Numbers
A worked example showing an LMC program that reads two numbers and outputs the difference (first minus second).
INP STA FIRST INP STA SECOND LDA FIRST SUB SECOND OUT HLT FIRST DAT SECOND DAT
Input: 10, 4 β Output: 6
Example 3: Counting Loop
User inputs a number (e.g., 3)
Store it in COUNT
Load COUNT into ACC
Output ACC
Subtract 1 from ACC
Store back in COUNT
If ACC = 0, jump to END (BRZ)
Otherwise, go back to LOOP (BRA)
HLT when done
Output for input 3: "3, 2, 1" then stops.
Branching & Conditionals in LMC
BRA (Branch Always)
Unconditional jump
Always goes to the given address
Used for:
loops
BRZ (Branch if Zero)
Jump only if ACC = 0
Used for:
checking equality, loop termination
Equivalent to:
if (acc == 0) goto label
BRP (Branch if Positive)
Jump only if ACC β₯ 0
Used for:
checking if a number is positive or not negative
Equivalent to:
if (acc >= 0) goto label
Tip:
Negative numbers in LMC are represented using values > 500 (two's complement style)
LMC vs Real CPUs β A Comparison
LMC
Real CPU
Memory
100 mailboxes (3-digit)
Billions of bytes (RAM + Cache)
Registers
1 (Accumulator)
Dozens (general-purpose, special)
Instruction Set
~10 simple instructions
Hundreds of instructions (CISC/RISC)
Addressing
Simple 2-digit address
Complex modes (direct, indirect, base+offset)
Data Size
3 digits (000β999)
32-bit or 64-bit integers and beyond
I/O
Simple IN/OUT
Complex device drivers and buses
Clock Speed
N/A (conceptual)
Billions of cycles per second (GHz)
Purpose
Teaching / Learning
Real-world computation
Despite its simplicity, LMC demonstrates ALL the core principles of real computer architecture: fetch-decode-execute, registers, memory addressing, and branching.
Key Takeaways
LMC is a simplified model of a Von Neumann computer β great for learning
Memory = 100 mailboxes; each stores a 3-digit number (data or instruction)
Only one register: the Accumulator (ACC), used for all calculations
The Fetch-Decode-Execute cycle is how every instruction is processed
~10 simple instructions: ADD, SUB, LDA, STA, INP, OUT, BRA, BRZ, BRP, HLT
LMC bridges the gap between high-level programming and real hardware
Try writing your own LMC programs at: peterhigginson.co.uk/lmc/ or cpulator.01xz.net
Questions?
- little-man-computer
- computer-architecture
- assembly-programming
- von-neumann
- cpu-design
- computer-science
- lmc-tutorial