Machine code is the only language the CPU can execute directly — binary instructions that control the processor. Each instruction consists of:
Example: 00100011 00001010 — opcode (LOAD) followed by operand (address 10 in binary)
The instruction set is the complete set of machine code operations a CPU can perform. Different CPU architectures (x86, ARM) have different instruction sets — meaning code compiled for one architecture does not run on another (portability problem).
Assembly language is a low-level language that uses human-readable mnemonics instead of binary. Each assembly instruction maps directly to one machine code instruction.
LDR R0, 100 ; Load value from memory address 100 into register R0 ADD R1, R0, #5 ; Add 5 to R0, store result in R1 STR R1, 200 ; Store R1 into memory address 200 CMP R1, #20 ; Compare R1 with 20 BEQ END ; Branch to END if equal
Assembly is converted to machine code by an assembler.
| Mode | Description | Example |
|---|---|---|
| Immediate | Operand IS the value to use | ADD R0, #5 → add 5 directly |
| Direct | Operand is a memory address containing the value | LDR R0, 200 → load value at address 200 |
| Indirect | Operand is address of address — follow the pointer | Operand 200 holds another address 500; load value at 500 |
| Register | Operand is a register | ADD R0, R1 → add contents of R1 to R0 |
After ALU operations, flag bits in the status register are updated:
Conditional branch instructions (BEQ, BNE, BGT) check these flags to decide whether to branch.
A typical 16-bit instruction word:
8 questions · instantly marked · AQA 7517 standard
LDR R0, #8 ; Load 8 into R0
ADD R1, R0, #3 ; Add 3 to R0 and store in R1
SUB R1, R1, #2 ; Subtract 2 from R1[3]| Term | Definition |
|---|
10 questions · 10 minutes