The syllabus expects candidates to recognise **seven programming paradigms**, understand their key characteristics, and be able to relate each paradigm to other parts of the course (hardware, data representation, system software, security, SDLC, etc.). This note focuses on the **low‑level paradigms** (machine language and assembly language) while giving concise over‑views of the other six paradigms and explicitly linking low‑level concepts to the rest of the syllabus.
| Paradigm | Typical Languages | Key Idea | Contrast with Low‑level |
|---|---|---|---|
| Procedural | C, Pascal, BASIC | Programs are a sequence of procedures/functions that manipulate data. | Uses abstractions such as functions and control structures; hides register‑level detail. |
| Object‑oriented | Java, Python, C++ | Data and behaviour are bundled into objects; supports inheritance and polymorphism. | Encapsulation abstracts away memory layout; low‑level code must manage layout manually. |
| Functional | Haskell, Lisp, F# | Computation is expressed as evaluation of pure functions; immutable data. | No explicit state or registers; low‑level code manipulates mutable registers directly. |
| Logical | Prolog | Programs consist of facts and rules; execution is based on logical inference. | Logical resolution is high‑level; low‑level code implements the inference engine in hardware. |
| Event‑driven | JavaScript (browsers), Visual Basic | Control flow is determined by events (user actions, messages). | Event‑loop is usually built on OS interrupt handling – a low‑level mechanism. |
| Concurrent / Parallel | Go, Java threads, OpenMP | Multiple threads or processes execute simultaneously, sharing resources. | Concurrency is realised by CPU scheduling, interrupts and atomic instructions – all low‑level concepts. |
| Low‑level (Machine & Assembly) | Machine language, Assembly language (e.g., x86, ARM) | Programming with little or no abstraction from the hardware. | Direct manipulation of registers, memory addresses and CPU instructions. |
| Characteristic | Explanation |
|---|---|
| Direct hardware manipulation | Registers, memory locations and I/O ports are accessed explicitly. |
| One‑to‑one mapping to machine operations | Each source statement usually becomes a single CPU instruction. |
| Minimal runtime overhead | Very fast execution; no garbage collector or virtual machine. |
| Platform specificity | Code is tied to a particular instruction set architecture (ISA). |
| Steep learning curve | Programs are harder to read, write and maintain. |
A machine instruction consists of an opcode (the operation to perform) and one or more operand fields (register numbers, memory addresses, or immediate data).
Example 16‑bit instruction format (generic):
$$\text{Instruction}= \underbrace{\text{opcode}}_{4\text{ bits}} \;\underbrace{\text{address}}_{12\text{ bits}}$$Because writing directly in binary is impractical for humans, assemblers and compilers generate machine code automatically.
Assembly replaces binary op‑codes with readable symbols and allows symbolic names for data locations. The syllabus requires knowledge of **five addressing modes**.
| Addressing Mode | Definition | Typical Syntax (x86‑like) |
|---|---|---|
| Immediate | Operand is a constant value encoded in the instruction. | MOV R0, #5 |
| Direct | Operand is a memory address given explicitly. | MOV R0, 0x1000 |
| Indirect | Operand address is stored in a register; the register’s contents are used. | MOV R0, [R1] |
| Indexed | Effective address = base register + index register × scale + displacement. | MOV R0, [R1 + R2*4 + 8] |
| Register | Both source and destination are registers. | ADD R0, R1, R2 |
;-------------------------------------------------
; Add two 8‑bit signed numbers stored at MEM_A and MEM_B
; Result is stored at MEM_RESULT
;-------------------------------------------------
LOAD R0, MEM_A ; R0 ← contents of MEM_A
LOAD R1, MEM_B ; R1 ← contents of MEM_B
ADD R0, R0, R1 ; R0 ← R0 + R1 (sets Carry flag if overflow)
STORE R0, MEM_RESULT ; store the sum
Each line corresponds to one machine instruction; the addressing mode used is direct** for the loads and store, and **register** for the addition.
LOOP:) is encountered, record its address (location counter) in a symbol table.Sample listing (two‑pass) (using a tiny fictional ISA):
| Source | Pass 1 Symbol Table | Pass 2 Machine Code |
|---|---|---|
START: LOAD R0, #10 | START → 0000 | 01 00 0A |
ADD R0, R0, #1 | 02 00 01 | |
STORE R0, RESULT | RESULT → 0006 | 03 00 06 |
HALT | FF | |
RESULT: .BYTE 0 | (data byte) |
Key CPU components (relevant to low‑level code):
Fetch‑Decode‑Execute Cycle (repeated millions of times per second):
00001101111100101111001111110011.
| Component | Role | Low‑level Connection |
|---|---|---|
| Operating System (OS) | Manages memory, processes, I/O, file systems. | Provides system calls (e.g., write()) that are thin wrappers around assembly routines; kernel itself is written in low‑level code. |
| Assembler | Translates assembly language to machine code. | Implements the two‑pass process described above; produces the executable that the CPU runs. |
| Compiler | Translates high‑level source to assembly/machine code. | Generates low‑level code on the programmer’s behalf; optimisation phases often emit assembly directly. |
| Interpreter / Virtual Machine | Executes high‑level statements one at a time. | VM itself is written in low‑level code (e.g., the Java Virtual Machine is largely C/assembly). Byte‑code is interpreted or JIT‑compiled to native instructions. |
| IDE / Debugger | Provides editing, building, and debugging facilities. | Debuggers display registers, memory, and step through machine instructions. |
socket(), send()) eventually invoke system‑call assembly routines.AND, XOR, SHIFT instructions.
; RDI points to start of buffer, RCX = length
MOV RBX, #3 ; shift amount
loop:
MOV AL, [RDI] ; load byte
ADD AL, BL ; shift
MOV [RDI], AL ; store back
INC RDI
DEC RCX
JNZ loop
Case study – Open‑source device drivers. A driver written in assembly can be released under the GPL, giving users the right to modify and redistribute the low‑level code. Discuss the impact on hardware manufacturers and end‑users.
INT 13h on x86).| Structure | High‑level view | Low‑level implementation hint |
|---|---|---|
| Array | Contiguous block indexed by integer. | Base address in a register; element i accessed as BASE + i·SIZE using indexed addressing. |
| Record / Struct | Fixed fields of possibly different types. | Fixed offsets from a base address; each field accessed with a constant displacement. |
| Linked List | Node contains data + pointer to next node. | Pointer stored in a register; follow link with LOAD R0, [R1] (indirect mode). |
| Binary Tree | Node with left/right child pointers. | Recursive traversal implemented using the call stack (push/pop) or an explicit stack in memory. |
Students should be able to express an algorithm both in pseudocode/flowchart form and, where appropriate, in low‑level assembly.
INPUT A, B // decimal numbers
CONVERT A, B to binary
PERFORM bit‑wise addition with carry
OUTPUT result in decimal
MOV R0, [A] ; load operand A
MOV R1, [B] ; load operand B
ADD R0, R0, R1 ; R0 = R0 + R1, Carry flag set on overflow
JC overflow ; optional overflow handling
STORE R0, RESULT
-13 to 8‑bit two’s‑complement binary (show the steps).R2 and R3 and stores the result in R4 (use register addressing).Create an account or Login to take a Quiz
Log in to suggest improvements to this note.
Your generous donation helps us continue providing free Cambridge IGCSE & A-Level resources, past papers, syllabus notes, revision questions, and high-quality online tutoring to students across Kenya.