BasketMC

Sequence Indexer Part 2, Episode 16: TIS-100

  • Published on

Episode 16 stays on Sequence Indexer, the segment Episode 15 started, and on its main problem: the stack memory node hands numbers back in the opposite order. Basket tries pouring one stack into the other to turn the order around, then adds a signal so the lookup waits. The puzzle is still unsolved when the video ends.

A failing run to start

The segment's text reads: "Sequences are zero-terminated. Read a sequence from IN.V. Read index values from IN.X. Look up index value in sequence. Write indexed value to OUT." IN.V feeds the top left node, IN.X the top of the third column, and OUT leaves from the bottom of the third column. Both stack memory nodes sit in the middle column.

The video opens on a run of the old program. OUT expects 860 first and gets a red 697. "Okay, I might have an idea." Basket moves the lookup code to another node and talks through pulling values off a stack and putting them back, then drops it: "Then I'll just keep on getting the same thing back." After "Okay, I will be back again," the video cuts.

TIS-100 Sequence Indexer running test 1: the top stack memory node holds a column of numbers ending in a red 0, the output column shows a red 697, and the center node starts with MOV LEFT RIGHT and L1:MOV RIGHT ACC.

Pouring one stack into the other

The new plan: "I'm going to move everything over to here, and I think it will reverse the order." The top left node fills the top stack, then switches to "L: MOV RIGHT DOWN" and "JMP L" to empty it. "MOV UP DOWN" and "MOV UP RIGHT" in the left column carry the values into the bottom stack. The center node does the lookup with L1 and L2 loops, a DONTSEND label and "SUB 1".

Stepping through, the top stack fills "sort of in the reverse order that we want," and then values start to land in the bottom stack.

TIS-100 Sequence Indexer mid-run: the top stack memory node holds 0, 860, 215, 230, 784, 900 and a red 978, the bottom stack memory node has begun to fill with 432 and a red 124, and the top left node's highlighted line reads L: MOV RIGHT DOWN.

Too early

Watching the center node, the commentary sees it grab a value before the move is done: "I guess I have to wait till the whole stack moves before I look at it." The left nodes get "MOV -1 RIGHT" and "MOV -1 UP" as a ready signal ("I'll do negative one just so I can make sure I see it"), and the center node gets "MOV LEFT NIL" so it holds until the signal arrives. The next run brings "Wait, what?" and then "Oh, the zero."

TIS-100 Sequence Indexer stepped through: the two left nodes both begin START: MOV UP ACC and end MOV -1 RIGHT and MOV -1 UP, a -1 and a 697 sit on the arrows between them, the top stack holds eight numbers ending in a red 124, and the bottom stack is empty.

Where the zero goes

The rest of the video goes into the zero that ends each sequence. "Do I want the zero at the beginning or the end? It kind of needs to be both." The bottom left node is rewritten to preload a zero with "MOV 0 RIGHT", stop on a zero with "JEZ GO", and send "MOV -1 UP" under a GO label.

TIS-100 Sequence Indexer editor: the bottom left node holds a new program with L:, MOV 0 RIGHT, L2:, MOV UP ACC, JEZ GO, MOV ACC RIGHT, JGZ L2 and GO: MOV -1 UP, next to the center node's L1 and L2 loop, with both stack memory nodes empty.

Where it ends

No test passes in this episode. The last thing on the recording is a plan for one more signal, "a signal coming down to say, start moving stuff," and the video cuts to the end card with the code still being written.