Recently I colleague of mine showed me a game on Steam called TIS-100. A little bit about the game, the developers have created a custom assembly language which runs inside a sandbox environment. I was able to pick it up cheap off a Steam sale, and after playing for a little I decided it was actually quite a fun game. And it was at this point I thought I’d write a quick little post about how I solved a challenge.
When you open a challenge, you are given a similar looking screen layout as below.
In the top left corner of the screen is the goal for the level, the middle of the left side is the input values and the expected out followed by your output. In the bottom left, is the control mechanisms of the environment. The boxes on the screen, are where the assembly instructions are created.
For this challenge, the goal is to read the values in from input A (“IN.A”), double that value and then write the result value to output A (“OUT.A”). Let’s begin with writing the required assembly, for this will need the TIS-100 assembly reference manual, the developers provide a copy within the game but for a quick reference follow this link: https://steamcommunity.com/sharedfiles/filedetails/?id=456879799
I’ll now explain what I programmed above. In the box in which IN.A flows into, I move the value coming in to the “ACC” register. I then add the value within “ACC” to itself, thus doubling itself. I then move the value in “ACC” down to the next control box which then directs result to the “OUT.A”. When the program is executed, we can see the assembly is performing the correct task in the output columns on the left.
This concludes the write-up for the “Segment 10981” challenge. I found this game quite enjoyable to play with a concept which has been executed very nicely. I highly recommend checking it out.