Teach Any Computer Science Class
We have put together a full GCSE Computer Science curriculum that will give you all the teaching materials you need to teach any topic.
Whether you're a brand new Computer Science teacher, or you've been teaching ICT for years, our resources will save you hours and hours of lesson preparation every single week.View the Lessons →
Labels are used to label a memory address. This makes it much easier to refer to memory addresses which hold data or instructions.
Example 1 – using labels with data:
- data1 DAT
- Explanation: The memory address where this data is stored would be labelled data1. No data would initially be stored at this location. If this was the 7th line of assembly code to be compiled then the label would refer to memory address 6 (RAM addresses start at 0)
- data1 DAT 50
- Explanation: The memory address where this data is stored would be labelled data1 and store the data 50. If this was the 7th line of assembly code to be compiled then the data 50 would be stored at memory address 6 (RAM addresses start at 0)
- STA data1
- Explanation: The contents of the accumulator would be stored at memory address 6.
- LDA data1
- Explanation: The data which is stored at memory address 6 would be loaded into the accumulator.
Example 2 – using labels with branch instructions: (i.e. BRP, BRA & BRZ)
- loop1 INP
- Explanation: The memory address where this instruction is stored would be labelled loop1.
- BRZ loop1
- Explanation: If the contents of the accumulator were zero, the program would branch to the memory address labelled loop1 and carry out the instruction there. To achieve this, the Program Counter would be set to the memory address labelled loop1.
- If the contents of the accumulator were not zero then the Program Counter would simply be incremented by one.
An example program using labels with data and branch instructions (it outputs the numbers 1 – 10 in sequence)
|start LDA store
store DAT 1
one DAT 1
limit DAT 10
|0 LDA 8
2 ADD 9
3 STA 8
4 LDA 10
5 SUB 8
6 BRP 0
8 DAT 1
9 DAT 1
10 DAT 10