Assembly language, addressing modes and system software

A-Level Computer Science · Hardware and Processor Fundamentals

Why assembly still appears

Assembly language is a one-to-one symbolic form of machine code: LDD, ADD, STO, JMP, CMP, JPE. It is used where speed or direct hardware control matters — device drivers and embedded systems — and in the exam because it shows whether you really understand what the processor does.

Four addressing modes

Given LDx n:

• Immediate (LDM #n): load the value $n$ itself.
• Direct (LDD n): load the contents of address $n$.
• Indirect (LDI n): address $n$ holds another address; load the contents of that.
• Indexed (LDX n): load the contents of address $n$ plus the index register — the mode that makes array processing possible in a loop.

Assemblers and translators

An assembler converts assembly to machine code, usually in two passes: the first builds a symbol table of labels, the second generates the code now that every label's address is known — which is why forward references work. A compiler translates a high-level program once, producing a fast standalone executable but reporting all errors together. An interpreter translates and runs line by line: slower and it needs the interpreter present, but it stops at the first error, which suits development.

The operating system

Memory management, file management, process scheduling, device management via drivers, security and the user interface. It exists to hide hardware detail from applications, so the same program runs on different machines.

Utility software

Defragmenter, backup, compression, antivirus, disk repair — housekeeping tools, distinct from the OS itself and from application software.

Worked example: telling the four addressing modes apart on the same memory

Memory: location $50$ holds $60$; location $60$ holds $85$; location $52$ holds $19$. The index register holds $2$.

State the value the ACC receives after each instruction: (a) LDM #50 (b) LDD 50 (c) LDI 50 (d) LDX 50.

Solution

(a) LDM #50: immediate. The $\#$ sign means the number itself is the operand, with no memory access. $\text{ACC}=\mathbf{50}$.

(b) LDD 50: direct. Go to location $50$ and take its contents. Location $50$ holds $60$. $\text{ACC}=\mathbf{60}$.

(c) LDI 50: indirect. Two steps: location $50$ holds $60$, but $60$ is interpreted as an ADDRESS; go on to location $60$ and take its contents, which is $85$. $\text{ACC}=\mathbf{85}$.

(d) LDX 50: indexed. Effective address $=50+2=52$; location $52$ holds $19$. $\text{ACC}=\mathbf{19}$.

How to remember without mixing them up. Count the number of "trips into memory": immediate makes $0$, direct makes $1$, indirect makes $2$. Indexed also makes $1$ but adds the index register first.

Why indexed addressing matters. To add up $100$ elements of an array starting at location $50$, we write one loop that uses LDX 50 and increments the index register each time round; the same instruction reaches a different address each time. Without this mode, $100$ separate instructions would be needed.

Common mistake

Confusing indirect with direct. LDD 50 takes the contents of location $50$; LDI 50 treats the contents of location $50$ as an address and takes one more step. Drawing two arrows on scratch paper is a sure way not to go wrong.

Key takeaway

The four addressing modes are told apart by the number of trips into memory. An assembler runs two passes to handle labels that come later. A compiler produces a fast executable and reports errors in one go; an interpreter stops at the first error, so it suits development.

← The fetch-decode-execute cycle and interrupts · All A-Level Computer Science lessons · Practice A-Level Computer Science questions (free, instant scoring) · Relational databases and normalisation →