Assembly Language, the LMC & Addressing Modes (OCR A-Level CS 1.2.4)

OCR A-Level CS 1.2.4: assembly language and the Little Man Computer instruction set, plus immediate, direct, indirect and indexed addressing. Exam tips


Free Assembly Addressing Modes revision resources (OCR A-Level Computer Science, 1.2.4)

We’ve made exam-style practice for this exact topic, free to download: Assembly Addressing Modes question sheet, mark scheme and cheat sheet. Grab them, have a go, then read the full guide below.

One step above raw machine code sits assembly language — and OCR tests it through the Little Man Computer (LMC), a simplified processor you must be able to read, trace and write programs for. Spec point 1.2.4 (full A-level) covers assembly and the LMC, plus the four modes of addressing memory, which has appeared as a full 12-mark discussion question.

This guide covers the LMC instruction set, tracing and writing LMC programs, and the four addressing modes.

What is assembly language?

Assembly language is a low-level language in which each instruction is a mnemonic (such as ADD or STA) that corresponds almost one-to-one with a machine-code instruction. An assembler translates it into machine code. Programmers choose assembly when they need direct control of the hardware or maximum speed and minimal memory, such as in embedded systems and device drivers — at the cost of being slower to write, harder to read, and not portable.

The Little Man Computer instruction set

The LMC is OCR's teaching model of a processor. The instructions to know:

  • INP — input a value into the accumulator.

  • OUT — output the value in the accumulator.

  • LDA addrload the value at a memory address into the accumulator.

  • STA addrstore the accumulator's value at a memory address.

  • ADD addr / SUB addr — add/subtract the value at an address to/from the accumulator.

  • BRA labelbranch always (jump) to a label.

  • BRZ label — branch if the accumulator is zero.

  • BRP label — branch if the accumulator is positive or zero.

  • HLT — halt the program.

  • label DAT n — reserve a data location (with optional initial value n).

Note which instructions change which registers: LDA, INP, ADD, SUB change the accumulator; the branch instructions change the program counter.

Worked example: following an LMC program

What does this program do?




Trace it with inputs 9 then 5: first = 9, second = 5, then the accumulator becomes 5 − 9 = −4. That is negative, so BRP does not branch; the program loads first (9) and outputs 9. Now with 4 then 7: the accumulator becomes 7 − 4 = 3, which is positive, so it branches to bigger, loads second (7) and outputs 7. The program outputs the larger of two numbers — a classic exam pattern. Always trace with the given inputs, recording the accumulator after every instruction.

Worked example: writing an LMC program

Add two numbers and output the total:




The first input is stored, the second is added to it in the accumulator, and the result is output. num1 DAT reserves the memory location.

What are the four modes of addressing?

An instruction's operand can be interpreted in different ways — the addressing mode says how to find the actual data:

  • Immediate — the operand is the value itself. No memory access needed.

  • Direct — the operand is the address of the value in memory (the LMC's normal mode).

  • Indirect — the operand is the address of a location that holds the address of the value. Useful for reaching a larger address space than the operand field allows, and for pointers.

  • Indexed — the real address is the operand plus the value in an index register. Incrementing the index register steps through an array in memory.

Why use assembly instead of a high-level language?

Assembly gives speed, small code size and direct hardware control, which matters in embedded systems and time-critical code. High-level languages are faster to write, easier to read and debug, and portable across processors. The classic 9-mark discussion asks you to weigh these for a given scenario — always conclude for the context given.

Common exam mistakes

  • Tracing in your head. Write the accumulator's value after every instruction; mark schemes credit method.

  • Confusing BRZ and BRP. BRZ branches only on zero; BRP branches on positive or zero.

  • Forgetting DAT. Every named memory location used by STA/LDA needs a DAT line.

  • Mixing up the modes. Immediate = value; direct = address of value; indirect = address of address; indexed = base + index register.

  • Saying assembly is "better". It is faster and smaller but slower to develop and not portable — answer for the scenario.

Quick recap

  • Assembly = low-level mnemonics, ~1:1 with machine code, translated by an assembler; used for control, speed and embedded systems.

  • LMC: INP, OUT, LDA, STA, ADD, SUB, BRA, BRZ, BRP, HLT, DAT. Branches change the PC; loads/arithmetic change the accumulator.

  • Trace LMC programs line by line, tracking the accumulator.

  • Addressing modes: immediate (operand = value), direct (operand = address), indirect (operand = address of address), indexed (operand + index register; great for arrays).

Frequently asked questions

What is assembly language? A low-level language where each mnemonic instruction corresponds almost one-to-one with machine code. It is translated by an assembler and gives direct control of the processor at the cost of being harder and slower to write.

What do the LMC instructions mean? INP inputs to the accumulator, OUT outputs it, LDA loads from memory, STA stores to memory, ADD and SUB do arithmetic with a memory value, BRA branches always, BRZ branches if the accumulator is zero, BRP if positive or zero, HLT stops, and DAT reserves a data location.

Which LMC instructions change the program counter? The branch instructions BRA, BRZ and BRP change the program counter when they branch. Instructions like LDA, INP, ADD and SUB change the accumulator instead.

What are the four modes of addressing memory? Immediate (the operand is the value), direct (the operand is the address of the value), indirect (the operand is the address of a location holding the value's address) and indexed (the address is the operand plus an index register).

When is indexed addressing useful? When working through arrays. The operand gives the base address and the index register the offset, so incrementing the index register moves to the next element without changing the instruction.

Why would a programmer choose assembly language? For maximum speed, minimal memory use and direct control of hardware, for example in embedded systems, device drivers or time-critical routines. For most software, high-level languages are preferred because they are faster to write, easier to maintain and portable.

 

 

 

Logo

All trademarks, logos and brand names are the property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names, trademarks and brands does not imply endorsement.


Follow us on:

Icon
Icon
Icon
Icon
Icon

Support@shuttlelearning.com

Logo

All trademarks, logos and brand names are the property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names, trademarks and brands does not imply endorsement.


Follow us on:

Icon
Icon
Icon
Icon
Icon

Support@shuttlelearning.com

Logo

All trademarks, logos and brand names are the property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names, trademarks and brands does not imply endorsement.


Follow us on:

Icon
Icon
Icon
Icon
Icon

Support@shuttlelearning.com