Write a complete Snake game in AQA Assembly Language
Downloaded: 1224
Last edit: 05 November 2021
UPDATE (7/1/2020): Please note that an updated and improved version of this resource, now appears within my Assembly Language Programming book, which may be downloaded from here. RP.
Background
This resource was created as a response to the difficulty of engaging pupils with assembly language programming when using only trivial examples such as adding two numbers, or finding the largest of three values. I wanted, instead, to give pupils the experience of writing a program that:
- Was non-trivial in difficulty (of the order of 100 machine instructions)
- Delivered a rewarding result
- Was appropriate to be written in assembly language
Most people who’ve played a few video games will have encountered ‘Snake’ at some point - probably on a PC or phone. Despite its simplicity it is a very engaging game, and many pupils will be keen to play it, and compete to achieve the longest snake.
Today’s pupils are just about old enough to remember simple hand-held video games that featured low-resolution liquid crystal displays. Those devices typically had 8-bit microprocessors and very limited memory. The games on those devices, such as Snake - all of them simple by today’s standards - had to be written in assembly language both for speed of execution and size.
The implementation
The implementation presented uses less than 100 machine-level instructions. It is written for the AQA Assembly Language, which is designed for an imaginary Risc processor loosely based on an ARM processor.
The Snake program will run on Peter Higginson's online AQA Processor Simulation . However, it would not take a great deal of effort to modify the final code to run on a real ARM processor, as used on the Rasberry Pi, equipped with a suitable memory-addressable display.
As well as helping to teach AQA Assembly Language programming, the exercise provides strong reinforcement for some other ideas covered in the A-level Computer Science syllabus such as:
- Agile software development methodology
- Linear and Circular Queue data structures (introduced in Story 7 and 8)
Acknowledgements
I am deeply indebted to Peter Higginson for:
- Creating and freely sharing his excellent online processor simulators. (He is best known in schools for his LMC simulation).
- Making several significant extensions, such as the addition of a memory-addressable graphics display, to the AQA simulation specifically to enable this Snake project. The changes he made for this project are detailed here under 'Version 0.7'.
- Providing me with a great deal of advice and guidance on the Snake coding itself, on an almost daily basis throughout January.
There are many implementations of Snake. I was originally inspired by Nick Morgan's version written for the 6502 (the last processor I wrote real assembly Language software for, back in the early 1980s). The version presented here started as a translation of Nick Morgan's version into AQA code, but has ended up very different.
Level: Advanced
Teaches:
- Assembly Language programming (using AQA specification)
- Immediate, Direct, Indexed, and Indirect Addressing Modes
- Agile software development methodology
- Linear and Circular Queue data structures
- Simple game design
Edit history
Unlock all resources and events
To access our full library of resources and events create a free account today or login.
If you like this resource make sure you add it to your resource collection to access again or share with the community.
Login Create Account