BasketMC

Signal Multiplier, Episode 9: TIS-100

  • Published on

Episode 9 opens on a puzzle the title does not name: Sequence Reverser, which puts stack memory nodes on the grid. Basket solves it in under eight minutes, then spends the rest of the video on Signal Multiplier. Both puzzles are solved on screen by the end.

Sequence Reverser

The puzzle text reads "Sequences are zero-terminated. Read a sequence from IN. Reverse the sequence. Write the sequence to OUT." Two nodes on the grid say "STACK MEMORY NODE", and the commentary admits to having no idea what they do: "We'll find out, I guess." Basket sends a few values into one and steps through to see which comes back out first.

The program that follows puts "MOV 0 RIGHT" ahead of its START label, so a zero sits in the stack before anything else. It pushes each value with "MOV ACC RIGHT" until "JEZ OUT" catches the zero at the end of a sequence, then pulls values back with "MOV RIGHT ACC" and "MOV ACC DOWN", looping on "JGZ OUT". The commentary notes it only works "as long as there's no negative numbers." It passes in 343 cycles with 4 nodes and 11 instructions, under a friend's score on cycles and instructions. "Whoa, how cool is that."

The Sequence Reverser screen running test 1: the node under IN holds "MOV 0 RIGHT", "START:", "MOV UP ACC", "JEZ OUT", "MOV ACC RIGHT", "JMP START", "OUT:", "MOV RIGHT ACC", "MOV ACC DOWN" and "JGZ OUT" beside a stack memory node, with single-line relay nodes leading down to OUT

Multiplying with additions

Signal Multiplier asks: "Read values from IN.A and IN.B. Multiply the values. Write the product to OUT." The segment map beside it shows a friend's score of five nodes and 22 instructions. "That's so many lines."

The Signal Multiplier editor before any code: the puzzle text reads "Read values from IN.A and IN.B", "Multiply the values" and "Write the product to OUT" above the IN.A, IN.B and OUT columns, next to a grid of empty nodes with a stack memory node at each end of the middle row

Basket wants a node that holds a number and hands it back on request, so the video goes to the Sequence Peak Detector program, where a node already stores values, and brings that code over. The copied node keeps a value with "SAV", returns it when sent a negative number ("JLZ RET"), and treats a 0 as the signal to send its value on ("JEZ OUTPUT").

A first idea, swapping and adding a number to itself, gets dropped after a moment's thought: "It's going to double each time. It's an exponent." The version that sticks puts one input in storage and uses the other as a counter in the center node. Each pass through "LOOP:" runs "SUB 1", sends "MOV -1 DOWN" to fetch the stored number, and adds it to a running sum kept in the backup register with "SWP".

Zeros break it

The first run fails. Basket adds a breakpoint and steps through: the early products come out right, but after a product of 0, the next two outputs show as red zeros where 32 and 30 belong. The commentary works it out: sending down a zero to mean "output" "doesn't work if you actually have zeros."

The Signal Multiplier screen running test 1: the output column shows 8, 4 and 0, then two red zeros where 32 and 30 are expected, while the center node runs a loop with "SUB 1", "MOV -1 DOWN" and "ADD DOWN" and the node below it holds a "JEZ OUTPUT" check

Six nodes

The fix drops the zero signal. The storage node now only saves and returns. The center node's "OUT:" swaps the sum back into its hand, sends it on with "MOV ACC RIGHT", and clears itself with "MOV 0 ACC" and "SWP", and two single-line nodes carry the result down to OUT. A few steps look right, so Basket runs it at full speed.

It passes in 2322 cycles with 6 nodes and 26 instructions, behind the friend's score on all three. The commentary considers moving nodes around, but the -1 that fetches the stored number makes it hard to give that node a second signal. "I'm satisfied enough with that." The segment map shows Sequence Reverser and Signal Multiplier as nominal, and the video cuts to the end card.

The Signal Multiplier editor with the finished six-node program: relay nodes under IN.A and IN.B, a center node with "LOOP: JEZ OUT", "SUB 1", "MOV -1 DOWN", "ADD DOWN" and "OUT: SWP", "MOV ACC RIGHT", a storage node below it with "JLZ RET" and "RET: SWP", and two nodes passing the result down to OUT