Comprehensive Student Workbook and companion Teacher's Guide with instructions to write a complete Snake video game in less than 100 machine code operations - to run on Peter Higginson's AQA Processor Simulation
Created by Richard Pawson
last edited Jan 07 2020 by Richard Pawson
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.
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:
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 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:
I am deeply indebted to Peter Higginson for:
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.
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