Revision Notes
OxfordAQA A-Level Computer Science: Machine code and assembly language (9645) – Revision Notes
Condensed revision notes for OxfordAQA A-level Computer Science topic 8: opcodes, addressing modes, the assembly instruction set and loops.
- Subject
- Computer Science
- Level
- AS LEVEL
- Topic
- Machine code and assembly language
- Author
- Marlbridge Academic Team
- Updated
Aligned to OxfordAQA A Level Computer Science (9645), 2024-onwards. Official specification .
Syllabus page (what it covers and how it is assessed): OxfordAQA A Level Computer Science.
Syllabus points this page covers
9645 (AS Level)
- 8 Machine code and assembly language (whole topic)
Found an error? Report a correction.
Need help with this topic? Request a free trial class for A Level Computer Science (9645).
Fuller explanations, and longer worked examples, sit in the study guide first. These notes condense topic 8, Machine code and assembly language (sections 3.8.1 and 3.8.2), of Version 1.1 of OxfordAQA’s International AS and A-level Computer Science (9645) specification, which applies to International AS exams in May/June 2025 and later and International A-level exams in May/June 2026 and later. Everything here is International AS content, assessed in the written Unit 2 paper and carried into the full International A-level.
Then test yourself with the practice set. Use the 9645 hub page for other topics, tick outcomes off on the checklist to print, and find weak spots with a free diagnostic. For assemblers and low-level versus high-level languages (section 3.6.3), see the topic 6 revision notes.
3.8.1 Key definitions
- Processor instruction set – all the instructions one processor can carry out. It is processor specific, so machine code for one processor type is not generally usable on another.
- Opcode – the part of an instruction that says which operation to perform.
- Addressing mode – says how to interpret the operand.
- Operand – the data the instruction works on: a value, a memory address or a register. An instruction can have one or more.
- Machine code – instructions expressed in binary.
- Assembly language – the same instructions expressed as mnemonics (
LDR,CMP,BNE…). - Instruction format – how the bits of an instruction are split up. It may depend on the type of instruction:
HALThas no operand,B labelhas one,SUB Rd, Rn, <operand2>has three.
You are not required to learn the format of any particular real instruction set. You must be able to work with a format a question gives you.
Method: decoding a given format
- Split the bit pattern into fields, left to right, using the widths given.
- Convert each field to denary.
- Number of possible opcodes = 2^(opcode bits); largest unsigned operand = 2^(operand bits) − 1.
- Use the mode field to say whether the operand is a value, an address or a register.
Small reminder: a 7-bit opcode field allows 2⁷ = 128 different opcodes.
3.8.1 Addressing modes
| Mode | The operand is … | Example | Value used |
|---|---|---|---|
| Immediate | the value itself | MOV R0, #12 |
12 |
| Direct | the address (memory location or register number) holding the value | LDR R0, 12 or ADD R0, R0, R7 |
contents of location 12; contents of R7 |
| Indirect | a register holding a main memory address | LDR R0, [R4] |
contents of the location whose address is in R4 |
Small reminder: if R4 holds 70 and location 70 holds 5, LDR R0, [R4] puts 5 in R0. MOV R0, R4 would put 70 in R0.
3.8.2 Instruction set summary
The OxfordAQA set is based on ARM. A copy is included in any exam paper with an assembly language question, according to the specification.
| Group | Mnemonics | Remember |
|---|---|---|
| Memory | LDR, STR |
Load = memory to register; store = register to memory |
| Arithmetic | ADD, SUB |
Result goes in the first register |
| Copy | MOV |
Copies operand2 into Rd |
| Compare | CMP Rn, <operand2> |
Sets up the next conditional branch |
| Branch | B, BEQ, BNE, BGT, BGE, BLT, BLE |
Condition reads “Rn ? operand2” from the last CMP |
| Logic | AND, ORR, EOR, MVN |
ORR is OR; EOR is XOR; MVN is NOT |
| Shift | LSL, LSR |
Logical: 0s come in, bits falling off are lost |
| Stop | HALT |
Ends execution |
- operand2 is
#n(a decimal value) orRm(the value in register m). - Registers R0 to R12 are available to the programmer.
- A label is an identifier then a colon:
top:. The branch names it without the colon:BNE top.
Must-know distinctions
#25versus25: the value 25 versus the contents of location 25.R3versus[R3]: the value in R3 versus the contents of the location R3 points at.MOVversusLDR:MOVtakes an immediate value or register;LDRreads main memory.BversusB<condition>: always jump versus jump only if the last comparison met the condition.EORversusORR: 1 OR 1 gives 1, but 1 XOR 1 gives 0.MVNversusEORwith all 1s: both invert every bit of a value of that width.- Logical shift left versus multiply: equal only while no 1 bits are lost off the top.
Bitwise and shift patterns
| Task | Instruction pattern | Why it works |
|---|---|---|
| Clear chosen bits | AND with 0s in those positions |
x AND 0 = 0, x AND 1 = x |
| Set chosen bits | ORR with 1s in those positions |
x OR 1 = 1 |
| Toggle chosen bits | EOR with 1s in those positions |
x XOR 1 = NOT x |
| Multiply by 2ⁿ | LSL Rd, Rn, #n |
Each shift left doubles |
| Divide by 2ⁿ (whole part) | LSR Rd, Rn, #n |
Each shift right halves, remainder lost |
Small reminder: 13 = 00001101. LSL by 2 gives 00110100 = 52. LSR 52 by 2 gives back 13.
Method in steps: pseudocode to assembly
Assignment such as x ← x + y (x at 33, y at 34):
LDR R0, 33
LDR R1, 34
ADD R0, R0, R1
STR R0, 33
If x is 16 and y is 9, location 33 ends with 25.
IF … ELSE
LDRthe values;CMPthem.- Branch to the THEN label on the condition, or to the ELSE label on the opposite condition.
- Write the block that falls through, then
B endto jump past the other block. - Write the other block after its label, then
end:.
WHILE loop
top:label, thenCMPand a conditional branch out of the loop on the opposite condition.- Loop body, including the update of the counter or pointer.
B top, then the label for the code after the loop.
Small reminder: n ← 3, then WHILE n < 100 double n.
MOV R0, #3
top: CMP R0, #100
BGE out ; opposite of "n < 100" leaves the loop
LSL R0, R0, #1 ; n ← n * 2
B top
out: HALT
R0 runs 3, 6, 12, 24, 48, 96, 192. The test fails at 192, so the loop ends with R0 = 192.
Assembly back to pseudocode: forward conditional branch = IF; backward branch = loop; give each register a meaningful variable name; turn LDR/STR with fixed addresses into named variables.
Trace tables: one column per register or memory location that changes, plus a column for “branch taken?”. Write a new row each time something changes. Check the loop’s exit test on the final pass.
Quick self-test
- Name the three parts an instruction consists of.
- State the addressing mode used by operand2 in
SUB R2, R2, #12. - R4 holds 70 and memory location 70 holds 5. What does
LDR R0, [R4]place in R0? - Which OxfordAQA mnemonic performs a bitwise NOT?
- R1 holds 00110101 (53) in an 8-bit register. Give R2 in binary and denary after
LSL R2, R1, #2. - Give the denary result of
AND R3, R1, #7for the same R1. - Which branch mnemonic means “branch if not equal”?
- R1 holds 10. After
CMP R1, #10, which ofBGT,BGEandBLTwould branch? - How many different opcodes can a 7-bit opcode field represent?
- R5 holds 01011100 (92) in an 8-bit register. Give the result of
EOR R6, R5, #255in binary and denary. - Why will a machine-code program written for one processor type not usually run on another?
- Which registers may the programmer use in the OxfordAQA instruction set?
Answers
- Opcode, addressing mode, operand(s).
- Immediate.
-
MVN.- 11010100 = 212 (no 1 bits were lost).
- 00110101 AND 00000111 = 00000101 = 5.
BNE.- Only
BGE(10 is not greater than 10 and not less than 10). - 2⁷ = 128.
- 10100011 = 163.
- Instruction sets are processor specific, so the binary patterns mean different things (or nothing) on another processor.
- R0 to R12.
Where marks are usually lost
- Writing an immediate value without
#, which changes it to a memory address. - Using
MOVto read a value from main memory; that needsLDR. - Getting the order of operands in
SUBwrong:SUB Rd, Rn, <operand2>gives Rn − operand2. - Placing the conditional branch before the
CMP, or comparing the wrong pair of registers. - Choosing the wrong condition when branching past a block (needing the opposite, such as
BLEto skip when “greater than” is false). - Missing the
Bthat jumps over the ELSE block, so both blocks run. - Updating the loop pointer after the
CMPinstead of before it, which gives one pass too few or too many. - Ignoring the register size in shift questions, so lost bits are still counted.
- Saying indirect addressing “uses an address” without saying the address is in a register.
- Writing pseudocode that simply renames each instruction instead of showing the IF or loop structure.
Official syllabus
OxfordAQA International AS and A-level Computer Science (9645) specification, Version 1.1, for International AS exams May/June 2025 onwards and International A-level exams May/June 2026 onwards, published by OxfordAQA. Section 3.8 Machine code and assembly language, and 6 Appendix: Standard OxfordAQA assembly language instruction set.
Get free revision emails (optional)
Occasional emails with practice questions, worked explanations and links to free resources for the qualification and subjects you choose. No spam, and you can unsubscribe from any email. The free tools on this site never need an email.
Related resources
-
Study guides
OxfordAQA A-Level Computer Science: Machine code and assembly language (9645)
Study guide to OxfordAQA A-level Computer Science topic 8: instruction format, addressing modes and writing and tracing assembly programs.
Computer Science · OxfordAQA · AS Level
Read guide -
Practice questions
OxfordAQA A-Level Computer Science: Machine code and assembly language (9645) – Practice Questions
Original practice questions with worked answers on OxfordAQA A-level Computer Science assembly: addressing modes, tracing and writing programs.
Computer Science · OxfordAQA · AS Level
Try questions -
Study guides
OxfordAQA A-Level Computer Science: Networking and cyber security (9645)
Study guide to OxfordAQA A-Level Computer Science networking and cyber security: transmission, LANs, the Internet, TCP/IP, DHCP and encryption.
Computer Science · OxfordAQA · A Level
Read guide
Related articles
-
teaching
A Level tuition in Dubai: Cambridge or Pearson Edexcel International A Level?
Schools in Dubai and Abu Dhabi teach either Cambridge International AS & A Level or Pearson Edexcel International A Level. How the two are structured, why it matters for tuition, and how online classes from Lahore work.
9 October 2026
-
curriculum guides
Choosing subjects at IGCSE and A Level
How subject choices at 14 and 16 affect university options later, and how to keep pathways open without overloading a timetable.
28 July 2026
Studying this with a teacher
Working through Computer Science AS LEVEL?
This page is free and stays free. If you would rather be taught it, Marlbridge runs Computer Science classes one-to-one and in small groups of up to 15, online in your own time zone. The first trial class is free. WhatsApp replies within an hour (8am–11pm Pakistan time, every day); email the same day.
OxfordAQA Computer Science teachers at Marlbridge