Low-Level Programming (Cambridge International A-Level Computer Science)
Low-level programming
How do I write low-level code using addressing modes?
- Machine code and assembly language are examples of low-level languages and were introduced in section 4 - Assembly Language Basics
- Before continuing, make sure you understand the different addressing modes
Immediate addressing
-
Syntax:
LOAD #value -
Meaning: Load a constant value directly into the accumulator
-
Use when you want to work with literal values, not data in memory
Direct addressing
-
Syntax:
LOAD address -
Meaning: Load the value stored at the specified memory address
-
Use when the data is stored at known memory addresses
Indirect addressing
-
Syntax:
LOAD @address -
Meaning: The address given points to another address, where the data is stored
-
Example:
- Memory[150] = 300
- Memory[300] = 42
LOAD @150loads 42 into the accumulator.
-
Use when data is stored in dynamically referenced locations
Indexed addressing
-
Syntax:
LOAD base[X] -
Meaning: Load from base address + index register (e.g.
X) -
Assume:
X = 2- This will access address 502 and 503
-
Use for working with arrays or tables, where the index changes
Relative addressing
-
Syntax:
BRANCH offset -
Meaning: Jump to a new instruction relative to the current instruction
-
Used in control flow:
-
Use for loops and conditional branches without needing absolute addresses
Was this revision note helpful?
Build on this topic