Assembly Language – LMC

Assembly language is a form of low level language where shortened words called mnemonics are used for each instruction. Because assembly language is low level it is closer to machine language, (that is the binary bit patterns but a computer uses).

programmerTo humans, assembly language can appear complex and difficult because every statement relates to a single instruction in the processor. This means that if the same code was written in a high level language one statement may need to be decomposed into many low level statements. Ultimately, the programs are doing the same thing, but one is more logical for a computer whereas is the other is more logical for a human.

smartwatchWhilst it might seem obvious to just program using a high level language, often embedded systems are written using assembly language as this allows the program to be smaller in terms of memory, and because embedded systems are rarely updated (if at all) then issues around changing the program aren’t there.

When writing in low level language it’s important to remember thanks the opcodes (the binary version of the instructions) are specific to the processor being written for. This is not the case in high level languages which are more portable across systems – the reason for this is that they are translated into the low level language that the processor uses.

The simulator below comes from Peter Higginson’s website and is an implementation showing how the LMC instructions can be used to run a low level language.

The LMC instruction set referred to at GCSE and is explicitly used for the OCR A Level.

When studying addressing modes at A Level, it is important to be aware that there are differences in the way that each exam board presents low level languages. Where OCR specifically uses the Little Man Computer instruction set, AQA uses a version similar to an ARM processor (the simulator created by Peter Higginson for that, may be accessed here).

Each of these use similar, but different instructions (as seen in the table below). Another major difference is that you will be given a table of instructions in the AQA & CIE exam where this is not the case for OCR.

OCRAQACIEPurpose
INPINPINPINPUT (from the user) & put value into the Accumulator
OUTOUTOUTOUTPUT the value that is in the Accumulator
LDALDRLD[?]LOAD Data into the Accumulator (from the address given)
For CIE, the 3rd symbol signifies the addressing mode
STASTRSTOSTORE the data in the Acculumulator (into the address given)
ADDADDADDADD the contents of the address to the value in the Accumulator
SUBSUBSUBSUBTRACT the contents of the address from the value in the Accumulator
BRPBGTBRANCH if Positive / BRANCH if Greater Than - allows for boolean conditions
BRZBEQBRANCH if Zero / BRANCH if Equal To - allows for boolean conditions
BRABBRANCH (always) - similar to an ELSE statement
HLTHALTENDHalts or ends the running of the program
DATlabelCreates a named piece of memory in the program (a variable)
LSLLogical Shift Left (Multiply)
LSRLogical Shift Right (Divide)

Sign in with your A Level account to read more about how these instructions are applied using different addressing modes.