Assembly Language and the Little Man Computer

A-Level Computer Science ยท Computer Architecture

Machine code and assembly language

The CPU only executes machine code (binary instructions). Assembly language is a low-level language that uses short mnemonics (like ADD, STA) in place of binary โ€” one assembly instruction usually maps to one machine instruction. It is processor-specific and translated to machine code by an assembler.

The Little Man Computer (LMC)

The LMC is a simplified model of a von Neumann CPU used to teach assembly. It has an accumulator, a program counter, and numbered mailboxes (memory). Typical instruction set:

MnemonicMeaning
INPInput a value into the accumulator
OUTOutput the accumulator
STA / STOStore the accumulator into a memory location
LDALoad a value from memory into the accumulator
ADD / SUBAdd / subtract a memory value to/from the accumulator
BRABranch (jump) always
BRZBranch if the accumulator is zero
BRPBranch if the accumulator is positive
HLTStop

Example โ€” add two inputs and output the total:

INP        // first number โ†’ accumulator
STA 99     // store it in mailbox 99
INP        // second number โ†’ accumulator
ADD 99     // add the stored number
OUT        // output the total
HLT

Instruction format

A machine-code instruction has two parts:

  • the opcode โ€” what operation to do (e.g. ADD);
  • the operand โ€” the data or the address of the data to use.

Addressing modes

How the operand is interpreted:

  • Immediate โ€” the operand is the actual value to use.
  • Direct โ€” the operand is the memory address where the value is stored.
  • Indirect โ€” the operand is the address of a location that holds the address of the value.
  • Indexed โ€” the address is found by adding the operand to an index register (useful for stepping through arrays).

Why use assembly?

  • Precise control of hardware and memory; can be highly optimised (speed/size).
  • Used for embedded systems, device drivers and time-critical code.
  • Drawbacks: harder to write, not portable (processor-specific).

Worked example

In ADD 99, what are the opcode and operand, and which addressing mode is typical here?

  • Opcode = ADD; operand = 99 (a memory address, mailbox 99) โ†’ direct addressing. โœ“

Common mistakes

  • Confusing immediate (operand is the value) with direct (operand is the address).
  • Forgetting LDA loads into the accumulator and STA stores from it.
  • Thinking assembly is portable โ€” it is processor-specific.

Exam tips

  • Learn the common LMC mnemonics and be able to trace or write a short program.
  • Know the opcode/operand split and the four addressing modes.
  • Give a reason to use assembly (control/optimisation) and a drawback (portability).

Key facts to remember

  • Assembly = low-level mnemonics, ~one-to-one with machine code, translated by an assembler, processor-specific.
  • LMC uses an accumulator + mailboxes with instructions like INP, OUT, LDA, STA, ADD, SUB, BRA, BRZ, BRP, HLT.
  • Instruction = opcode + operand; addressing modes: immediate, direct, indirect, indexed.
Test yourself on Computer Architecture

5 quick A-Level Computer Science questions, marked instantly, so you know what stuck. Free account, no card needed.

Start the free quiz โ†’
Don't understand a part?

Sign in and ask our AI tutor to explain any passage in plain English.

Try AI explanations โ†’

More on Computer Architecture

Instruction Sets and Pipelining Parallel Processing and GPUs

โ† All A-Level Computer Science notes