| Field | Size (bits) | Purpose |
|---|---|---|
| Opcode | 4 | Identifies the operation (ADD, LDM, MOV …). |
| Operand 1 | 4 | Register number or high‑order address bits. |
| Operand 2 | 4 | Register number, low‑order address bits or immediate value. |
| Operand 3 | 4 | Register, immediate value, or unused (depends on instruction). |
Assume the following opcode and register encodings (binary):
01110000–1111Assembly: ADD R1, R2, R3
01110001, R2 = 0010, R3 = 00110111 0001 0010 00110x7123The assembler must resolve forward references (labels that appear later in the program). It therefore works in two passes.
| Pass | What is Done |
|---|---|
| First Pass |
|
| Second Pass |
|
START: LDM R0, VALUE ; load address of VALUE (forward reference)
JMP END
VALUE: .WORD 0x55
END: HLT
VALUE at address 0x0006 and END at 0x0008.LDM R0, 0x0006 → 0x1006JMP 0x0008 → 0xE008HLT → 0xF000How an operand’s location is specified.
| Mode | Syntax (example) | Meaning | Typical Encoding (illustrative) |
|---|---|---|---|
| Immediate | LDI R1, #0x3A | Constant value is embedded in the instruction. | Opcode = 0011, Rd = 0001, 8‑bit constant = 00111010 |
| Direct | LDD R2, 0x30 | Address field gives the exact memory location. | Opcode = 0010, Rd = 0010, address = 00110000 |
| Indirect | LDR R3, (R4) | Register contains the address of the operand. | Opcode = 0101, Rd = 0011, Rb = 0100 |
| Indexed | LDX R5, 0x04(R6) | Effective address = contents of R6 + offset 0x04. | Opcode = 0100, Rd = 0101, Rb = 0110, offset = 00000100 |
| Relative (branch) | JMP LOOP | Signed offset from the current PC to the target label. | Opcode = 1110, 8‑bit signed offset (calculated in Pass 2). |
| Mnemonic | Opcode (binary) | Operand format | Example assembly | Machine code (hex) |
|---|---|---|---|---|
| LDM | 0001 | Rd, address (direct) | LDM R0, 0x20 | 0x1120 |
| LDD | 0010 | Rd, address (direct) | LDD R1, 0x30 | 0x2130 |
| LDI | 0011 | Rd, #constant (immediate) | LDI R2, #0x0F | 0x320F |
| LDX | 0100 | Rd, offset(Rb) (indexed) | LDX R3, 0x04(R4) | 0x4344 |
| LDR | 0101 | Rd, (Rb) (indirect) | LDR R5, (R6) | 0x5566 |
| MOV | 0110 | Rd, Rs | MOV R7, R8 | 0x6788 |
| ADD | 0111 | Rd, Rs, Rt | ADD R9, R10, R11 | 0x79AB |
| SUB | 1000 | Rd, Rs, Rt | SUB R12, R13, R14 | 0x8CDE |
| AND | 1001 | Rd, Rs, Rt | AND R0, R1, R2 | 0x9012 |
| OR | 1010 | Rd, Rs, Rt | OR R3, R4, R5 | 0xA345 |
| JMP | 1110 | label (relative) | JMP LOOP | 0xE0?? |
| HLT | 1111 | none | HLT | 0xF000 |
In the JMP entry the low‑order byte (shown as ??) is the signed offset calculated during Pass 2.
LDI R0, #0xAB ; R0 = 1010 1011₂
AND R0, #0x0F ; mask = 0000 1111₂ → R0 = 0000 1011₂ (= 0x0B)
LDI R1, #0x08 ; 0000 1000₂ – the flag we want to set
OR RCTRL, R1 ; RCTRL = RCTRL | 0x08
; R2 contains –8 = 1111 1000₂ (two’s complement)
ASR R2, #1 ; result = 1111 1100₂ = –4
LDI R0, #0x7F ; 0111 1111₂ (127)
LDI R1, #0x01 ; 0000 0001₂ (1)
ADD R2, R0, R1 ; R2 = 1000 0000₂ (–128 in two’s complement)
; Carry into sign bit = 0, carry out = 1 → overflow flag set
| Topic | Key Points to Cover (AO1‑AO3) |
|---|---|
| Data Representation | Binary, hexadecimal, signed/unsigned integers, two’s complement, floating‑point (IEEE‑754 single precision), character encodings (ASCII, Unicode). |
| Algorithms & Problem Solving | Flowcharts, pseudocode, basic constructs (sequence, selection, iteration), algorithm efficiency (Big‑O), recursion basics. |
| Data Structures | Arrays, records/structures, linked lists (conceptual), stacks and queues, simple tree concepts. |
| Computer Architecture | CPU components (ALU, registers, control unit), bus systems, cache hierarchy, RAM vs ROM, interrupts. |
| System Software | Operating system functions (process management, memory management, I/O control), language translators (assembler, compiler, interpreter), IDE features. |
| Communication & Networks | LAN/WAN concepts, topologies, Ethernet/CSMA‑CD, Wi‑Fi basics, TCP/IP stack, IPv4/IPv6 addressing, DNS, client‑server vs peer‑to‑peer, cloud computing. |
| Security & Privacy | Authentication, firewalls, malware types, encryption basics (symmetric vs asymmetric), SSL/TLS, digital certificates, hashing, data integrity checks. |
| Ethics, Legal & Environmental Issues | Intellectual property, data protection laws, ethical use of data, e‑waste, sustainable computing. |
| Databases | Relational model, tables, primary/foreign keys, normalization (1NF‑3NF), SQL DDL/DML statements, basic queries. |
| Software Development Life‑Cycle (SDLC) | Planning, analysis, design, implementation, testing, maintenance; agile vs waterfall; version control basics. |
| Testing & Evaluation | Unit testing, integration testing, black‑box vs white‑box, debugging techniques, performance evaluation. |
| Extension | Essential Content for Exams |
|---|---|
| Advanced Computer Architecture | RISC vs CISC, pipelining, superscalar execution, hazards, virtual memory, address translation (MMU, page tables). |
| Virtual Machines & Interpreters | Bytecode execution, stack‑based vs register‑based VMs, just‑in‑time (JIT) compilation. |
| Floating‑Point Representation | IEEE‑754 single and double precision layout, rounding modes, overflow/underflow handling. |
| Boolean Algebra & Karnaugh Maps | Simplification of logic expressions, design of combinational circuits, minimisation using K‑maps. |
| Encryption & Cryptography | Symmetric algorithms (DES, AES basics), public‑key concepts (RSA), hash functions, digital signatures. |
| Artificial Intelligence Foundations | Search algorithms (BFS, DFS, A*), basic machine‑learning concepts, neural‑network structure, ethical considerations. |
| Advanced Programming Paradigms | Object‑oriented concepts (classes, inheritance, polymorphism), functional programming ideas (higher‑order functions, recursion), exception handling. |
| Recursion & Stack Management | Recursive algorithm design, call stack behaviour, tail recursion optimisation. |
| Concurrency & Parallelism | Threads, processes, synchronization primitives (locks, semaphores), race conditions, deadlock. |
Problem: Increment each element of a 4‑byte array stored at address 0x1000 by the constant #5.
for i = 0 to 3
array[i] = array[i] + 5
LDI R0, #0x1000 ; base address of array
LDI R1, #4 ; loop counter
LOOP: LDR R2, (R0) ; load array[i]
ADD R2, R2, #5 ; add constant 5 (using immediate mode)
STR R2, (R0) ; store back
ADD R0, R0, #1 ; next byte address
SUB R1, R1, #1
BNE LOOP ; branch if R1 ≠ 0
HLT
LDI R0, #0x1000 → 0x3000 (illustrative)LDI R1, #4 → 0x3104LDR R2, (R0) → 0x5200ADD R2, R2, #5 → 0x7205STR R2, (R0) → 0x6300ADD R0, R0, #1 → 0x7001SUB R1, R1, #1 → 0x8101BNE LOOP → 0xE0F9 (offset –7 bytes)HLT → 0xF000Your 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.