In my last article, I gave a rundown of what TIS-100 is and how it works. Today, I will be building on this groundwork. This article will discuss programming patterns I have discovered in the game, some of them are pretty simple to downright obvious, others are sophisticated, but they all have a theme – these ones have helped me solve problems in the game.
Please do not consider the concepts in isolation; use them together to compose simple and efficient solutions to complex problems.
Loops
Loops are a foundational programming concept; they allow us to break up complex patterns into small repeatable units. In TIS-100, descending loops are the easiest and most flexible. There are countless variations you can make of them. To keep from getting caught in the weeds, I will only give a single example for reach.

This Decrementing-Loop is as simple as it gets. Here we repeat MOV 1 DOWN exactly 10 times. The reason these loops are the easiest is 3-fold: they are short, they require only 1 register, and they require only one check.
The implications are that the iteration count can easily be dynamically loaded at runtime, and the iteration count can be used for other purposes too.
The Incrementing-Loop gets a bit messy and takes a few additional instructions, because we must destroy and recover the main register in order to check if it is 10. The main use of incrementing loops is where the loop counter values 1, 2, 3 etc, are required for some computation.
A significant drawback is that the 10 is hard-coded. There are workarounds to this issue, such as the external register pattern below, but they add extra complexity. Wherever possible, use the descending loop instead

As we see, loops in TIS-100 are a bit tedious, but very important to our computing needs. To make the most of loops, be aware that they must be combined with other patterns to make the most of them.
Sentinel Values

Sentinel values are a very simple concept that is very powerful. They are specially chosen numbers that hold a meaning to you. In TIS-100, they are extremely common and useful in all of computing. The TIS-100 game itself often gives lists that end in sentinel values.
Sending a value such as -1 to another machine is cheap and can be used to transfer any required state information. For example, you can use them to dedicate machines to being loop counters, to handle expensive calculations, to signal the end of a list of values, to signal a reset, or anything at all. They allow you to offload all but the most essential information to another machine. Abstraction time, baby! Common sentinel values are 0 and -1 because they are small and uncommon in data, but anything can be used.
A particularly good pairing with sentinel values is the JRO instruction. JRO can be paired with handpicked sentinel values in order to conditionally jump to anywhere at all in code without overwriting the register.
External Register

The External Register pattern uses a dedicated machine to briefly save a value. The benefits of this pattern are as follows. The main machine is free to overwrite its register and SWP without consequence. Saving a value is extremely useful – freeing up the only register in the main machine allows for any kind of calculations to take place without losing data.
It may also be combined with the Double-send pattern below to allow for several operations while retaining data.
A useful variation of this idea is to swap the main register on each run, making this external register into a double-buffer holding 2 values.
Notify signals
Notify Signals are used to let a machine know when it should do something. Any dummy value can be used, but NIL is preferred because it makes it clear that the value of the number has no special meaning.
This pattern is a simple solution to machine synchronization issues. A common conundrum is that some work must be done in a specified order, split up over several independent machines, and the amount of time required varies. Signalling completion of a particular job is a simple and effective way to prevent data race conditions.

Double-send

Yup, it’s exactly what it sounds like! The Double-send pattern is simply sending data twice (or more than once). Since arithmetic in TIS-100 always modifies the main register, having plenty of options to make data easier to retain and move is critical.
Signal Repeater

The Signal-Repeater Pattern looks more complicated than it is; it’s very similar to Double-Send, except it is more generalized. The signal is sent a specific number of times. As you may expect, it is composed of a for loop and repeated sending.
Additionally, it is useful to combine the signal repeater with Sentinel-values to signal the start or end of a repeated signal.
A Note to The Operator
All the details I’ve given are quite surface-level. If you want to understand how these mechanisms work deeply, you should buy the TIS-100 game now! There are who-knows-many novel patterns to be found in TIS-100, and potentially infinite ways to implement the ideas I’ve shown. The game’s level design is done well enough that these kinds of solutions arise naturally from the constraints given, and it’s a lot of fun.
The subtext of this article is that TIS-100 has a simple but capable programming language. It is designed well enough that basic programming patterns arise naturally through playing. If you find this game at least a little interesting, you should also look into software development and factory games!
If you liked, hated, or didn’t mind this article, please send me your feedback. Bye.