GCSE Programming Resources (14-16 years)
- An editable PowerPoint lesson presentation
- Editable revision handouts
- A glossary which covers the key terminologies of the module
- Topic mindmaps for visualising the key concepts
- Printable flashcards to help students engage active recall and confidence-based repetition
- A quiz with accompanying answer key to test knowledge and understanding of the module
A-Level Software Resources (16-18 years)
- An editable PowerPoint lesson presentation
- Editable revision handouts
- A glossary which covers the key terminologies of the module
- Topic mindmaps for visualising the key concepts
- Printable flashcards to help students engage active recall and confidence-based repetition
- A quiz with accompanying answer key to test knowledge and understanding of the module
Introduction to LMC Addition and Subtraction
The following program will demonstrate the ADD and SUB instructions of the LMC instruction set.
INP
STA first
INP
ADD first
OUT
INP
SUB first
OUT
HLT
first DAT 0 INP
1 STA 9
2 INP
3 ADD 9
4 OUT
5 INP
6 SUB 9
7 OUT
8 HLT
9 DAT 0
Instructions
- Copy the ten line program above and paste it into the Program box.
- Click on the “Assemble Program” button.
- After the program is assembled you should see RAM addresses 0 to 8 contain the machine code instructions shown in the image.
- Click on the RUN button.
- If you have difficulty following what is happening, read the explanation below and use STEP instead of RUN so you can follow each step.
Explanation
0 INP //the first input value is loaded into the accumulator.
1 STA first //the accumulator contents are stored in RAM address 9 (labelled
first).
2 INP //the second input value is loaded into the accumulator.
3 ADD first //add the contents of RAM address 9 (labelled first) to the
accumulator and store the result in the accumulator.
4 OUT //the value in the accumulator is sent to the OUTPUT.
5 INP //the third input value is loaded into the accumulator.
6 SUB first //subtract the contents of RAM address 9 (labelled first) from the
accumulator and store the result in the accumulator.
7 OUT //the value in the accumulator is sent to the OUTPUT.
8 HLT //the program halts.
Example results
INPUT= 2 (stored in RAM address 9)
INPUT = 3
OUTPUT = 5 (the contents of the accumulator PLUS the contents of RAM address 9)
INPUT = 8
OUTPUT = 6 (the contents of the accumulator MINUS the contents of RAM address 9)