SLIDE 1 / 10
CSZone.co.uk
Click anywhere to advance · Arrow keys also work
AQA 7517 · Paper 2 · 4.7.4

LMC
Instruction Set

Little Man Computer · Assembly language simulation · Section 4.7

WHAT YOU'LL LEARN
LMC model · Full instruction set · Tracing programs · Writing LMC code · Addressing
AQA SPEC LINK
4.7.4 — The Little Man Computer (LMC) instruction set
What is LMC?

The Little Man Computer

The Little Man Computer (LMC) is a simplified model of a CPU with a single accumulator (ACC) and 100 memory mailboxes (00–99). Used to teach how real assembly language and the FDE cycle work.
3-digit memory addresses (00–99); 3-digit data values (000–999)
Single accumulator (ACC) stores results; single PC (Program Counter)
Uses mnemonics: ADD, SUB, LDA, STA, BRA, BRZ, BRP, INP, OUT, HLT, DAT
LMC Instructions

Full LMC Instruction Set

MnemonicAction
ADD xxACC ← ACC + Memory[xx]
SUB xxACC ← ACC − Memory[xx]
LDA xxACC ← Memory[xx] (load)
STA xxMemory[xx] ← ACC (store)
INPACC ← user input
OUTOutput value of ACC
BRA xxPC ← xx (unconditional branch)
BRZ xxIf ACC=0: PC ← xx (branch if zero)
BRP xxIf ACC≥0: PC ← xx (branch if positive)
HLTStop execution
Worked Example 1

Add Two Numbers

INP // Input first number → ACC
STA num1 // Store ACC at num1
INP // Input second number → ACC
ADD num1 // ACC ← ACC + num1
OUT // Output ACC (sum)
HLT // Stop
num1 DAT 0 // Data store initialised to 0
DAT declares a memory location for data storage (like a variable in RAM).
Worked Example 2

Count Down to Zero

INP // Get starting number
STA count // Store it
loop LDA count
OUT // Print current count
SUB one // count ← count - 1
STA count
BRZ end // If count = 0, jump to end
BRA loop // Else repeat
end HLT
count DAT 0
one DAT 1
Tracing LMC

Trace Table

AQA exams often ask you to trace through LMC code and complete a table showing ACC, PC, and mailbox values at each step. Input: 3
PCInstructionACCcount
0INP30
1STA count33
2LDA count33
4SUB one23
5STA count22
Addressing

Addressing Modes in LMC

Direct addressing — LDA 50 loads value from mailbox 50 into ACC
Immediate addressing — not in standard LMC, but in real CPUs: LDA #50 loads the literal value 50 (not what's stored at address 50)
Labels — in LMC mnemonics, labels like 'count' and 'loop' are replaced with actual addresses by the assembler
DAT — declares storage; DAT 5 initialises the location to 5
AQA Exam Style

Practice Question

AQA 7517 — Paper 2 Style
(a) State what the LMC instruction BRZ does and when it executes the branch. [2]
(b) Write LMC code to: input two numbers, output the larger one. [5]
(c) Explain the purpose of a DAT instruction in LMC. [1]
[8 marks]
2 marks
(a) BRZ branches to a specified address [1]; the branch only occurs if the value in the accumulator is zero [1]
5 marks
(b) INP / STA num1 / INP / STA num2 / SUB num1 / BRP output2 / LDA num1 / BRA done / output2 LDA num2 / done OUT / HLT / num1 DAT 0 / num2 DAT 0 [5 for logically correct program]
1 mark
(c) DAT declares a memory location to be used as a data store (variable); optionally initialises it with a value
Summary

Key Points to Remember

LMC — 100 mailboxes, one ACC, one PC; simplified CPU model
Instructions — LDA/STA (load/store), ADD/SUB (arithmetic), INP/OUT (I/O), HLT
Branches — BRA (always), BRZ (if ACC=0), BRP (if ACC≥0) — implement loops and conditions
DAT — declares a memory location (variable); optionally initialised with a value
Trace tables: show ACC and memory contents step-by-step — practice this!
🎉 Lesson complete — move to the quiz!