This is a list of games that I've enjoyed playing, that have something to teach you about low level programming in Assembly languages.
Have you ever wondered how software goes from the code in a high level programming language to electrical signals in your computer's processor? There are many other steps along the way, but the last step that would reasonably be seen as programming instead of hardware as is called an assembly language.
Assembly languages are different from higher level programming languages in that they usually have a close correlation with the actual functioning of the hardware. Each instruction in your assembly language probably has a circuit that does exactly what your instruction says. That one to one mapping with hardware means that different processors have different assembly languages. This raises the question: how do you learn about programming with assembly when each bit of hardware might have its own completely different language?
The good news is that there are many similarities between different assembly languages. For example, you don't have higher level branching operations like if statements or loops. The only type of branching that you have is the ability to jump to different lines. From that ability to jump to different lines, you will express patterns that look a lot like an if statement or a loop.
I first learned about assembly programming in university, when I needed to do things with a PIC16F690 microcontroller. It was fantastic to see the process from writing some weird instructions to having an LED blinking on a breadboard.
If you're looking for a serious learning resource, I can recommend the From Nand to Tetris course on Coursera. If you drop the requirement of looking for a "serious" resource, then there are other interesting ways to learn assembly programming. Like assembly programming games! Here are a few of my favourites.
Disclaimer: Humble Partner Program
I’m part of the Humble partner program, so buying from them after following the links that I'm including in this article will help to support this blog. That's why the links all point to the Humble Bundle site. You can also find these games in other places where games are sold if you prefer.
Human Resource Machine
Buy Human Resource Machine here
This is one of my favourite games of all time. Not only is it a compelling game about assembly programming, but it manages to look downright adorable while doing it.
The computer that you're programming in Human Resource Machine is an office worker. When you run your program, they dutifully grab items from the inbox, maybe make some use of your computer's memory (the floor), and puts items in the outbox. When you add two numbers, your office worker grabs the two numbers above their head and smashes them together. Incrementing a counter is done by giving it a good kick.
The visualization makes it easier to understand what the commands actually do. For example, I think this game does one of the best jobs of showing how to use pointers. That is, having a box on the floor that holds the address of the box that you actually want to be working with.
Each level has an optimization challenge, where you either need to optimize your program to run as fast as possible or have as few instructions as possible. It isn't always possible to beat both challenges with the same program. Needing to do these challenges shows you why compilers often let you choose to optimize for either space or speed.
I'm anxiously awaiting the followup game that's currently in development.
Buy TIS-100 here
TIS-100 takes a more serious tone. Your computer is made up of a 4 by 3 grid of independent microprocessors. Each is limited in the number of instructions it can run. If you need more than 15 lines of assembly code, you're going to have to spread it over multiple processors.
The central idea you can learn from here is getting high throughput in a device that has many pieces working in parallel. Like with real processors, you want to avoid having one part of the pipeline stuck doing nothing while it's waiting for data. The limited size of each block also sometimes leaves you scratching your head trying to figure out how to fit everything you need a block to do into its limited programming space.
Something that made TIS-100 stand out for me is that you get your instructions as a PDF manual to dig through. This reminded me so much of my university days trying to figure out how to use that PIC microcontroller from its data sheet.
Buy Shenzhen I/O here
This is a spiritual successor to TIS-100. Rather than having the computation modules soldered together, you select and connect the modules yourself.
Shenzhen I/O holds the distinction on this list of being the only one to pretend you're actually building something useful. In Human Resource Machine, you're implementing computer sciency algorithms because your boss tells you to. In TIS-100, you're implementing computer sciency algorithms because you're trying to repair the mysterious computer you found. In Shenzhen I/O, the story involves you having a job, building laser tag systems and sandwich makers that wave flags!
This also drives home that assembly languages are for serving hardware. Components are wired together, and put signals onto wires to communicate with the outside world. Also, like with real wires, you need to carefully consider the physical space that it take up. You've dealt with spaghetti code? Try spaghetti wiring! Finding the physical space to lay out your board in Shenzhen I/O can be a real challenge at times.
These games are fantastic in that they present a complete assembly language and have you solve problems with it. This on its own can give you a great insight into what your computer is actually doing when you write high level code. I hope you have as much fun with them as I have!
Send me a message if you know of any other particularly well done programming games.