Assembly language

Computer Science AS · Processor fundamentals. The idea in plain words, the rules to remember, the mistake to avoid and a worked example, written and checked by Mega Lecture.

Test this topic freeAll Computer Science AS topics

The idea

Machine code is the binary code a processor runs directly. Assembly language writes the same instructions with short names (mnemonics) such as LDD and ADD, and with labels in place of addresses. Each assembly instruction has an opcode, which says what to do, and usually an operand. One assembly instruction normally becomes one machine code instruction.

An assembler does the translation. A two-pass assembler reads the program twice, so that a label can be used before the line where it is defined.

The addressing mode tells the processor how to use the operand: as the value itself, as an address, or as a way of working out an address.

Rules to remember

Common mistake

Students load the address in place of its contents. LDM #60 puts the number 60 in ACC, but LDD 60 puts the contents of address 60 in ACC.

Worked example

Address 60 contains 12 and address 61 contains 5. What does address 62 contain after this program?
LDD 60
SUB 61
CMP #7
JPE SKIP
INC ACC
SKIP: STO 62

  1. LDD 60: ACC = 12 (the contents of address 60).
  2. SUB 61: ACC = 12 − 5 = 7.
  3. CMP #7: ACC equals 7, so the compare is True and JPE jumps to SKIP; INC ACC is not run.
  4. STO 62: the value 7 is copied to address 62.

Answer: Address 62 contains 7.

Ask about this

Type what you are stuck on. The helper finds the explanation, worked examples and the notes to read, free and instant.

Keep going

← Central Processing Unit (CPU) architectureBit manipulation →Take a Computer Science AS test