BasketMC

Signal Multiplexer, Episode 2: TIS-100

  • Published on

Episode 2 picks up in the Signal Comparator editor where Episode 1 stopped, with the commentary set on cutting the instruction count down to a friend's score. Then two new segments pass, Signal Multiplexer and Sequence Generator, and the second gets a rework to save a node. Everything open at the end of the video has passed.

Fewer lines for the comparator

The commentary works out that the value can be sent on with "MOV ACC, RIGHT" before the jump instead of after it, which removes the copy under FAIL and the extra jump at the end. The new run passes in 278 cycles with 6 nodes and 20 instructions, the same three numbers as the friend's line.

The Signal Comparator editor: three nodes along the bottom row above OUT.G, OUT.E and OUT.L each start with "START:", "MOV LEFT, ACC" and a JGZ, JEZ or JLZ jump to SUCCESS, the first two with "MOV ACC, RIGHT" moved up near the top, and the last node shows an empty "FAIL:" label

Picking an input

Signal Multiplexer reads values from IN.A and IN.B and one from IN.S, and writes IN.A when IN.S is -1, IN.B when it is 1, and IN.A + IN.B when it is 0. The nodes under IN.A and IN.B pass their values toward the IN.S node, which does the work: "MOV UP, ACC", then "JEZ ADD" and "JGZ RIGHT". One case sends the left value down and throws the right one away with "MOV RIGHT, NIL"; ADD sends down the sum. Along the way the commentary finds that a node has a maximum number of lines, and that blank lines count.

Out of step

On the first run the output does not line up, and a wrong value turns red in the OUT column. "These should all be lined up." The fix is to go back to the start after each case, but the node is out of lines, so the LEFT label comes out ("you have to just trust me") and START and "JMP START" go in. It passes in 263 cycles with 5 nodes and 16 instructions. The friend's line has the same nodes and instructions in 204 cycles.

The Signal Multiplexer screen running test 1: the node under IN.S holds "MOV UP, ACC", "JEZ ADD", "JGZ RIGHT" and RIGHT and ADD sections, two nodes below pass values down to OUT, and the third value in the output column, -23, is shown in red

Lesser value first

Sequence Generator wants zero-terminated sequences: read from IN.A and IN.B, write the lesser value, then the greater, then a 0. The first version sends IN.A over twice from one node, and the node beside it keeps the IN.B value with "SAV", subtracts and jumps with "JGZ B". The first test writes each pair in reverse order, so JGZ becomes "JLZ". It passes in 155 cycles, but with 5 nodes and 19 instructions against the friend's 4 and 18.

The Sequence Generator editor with the first version of the program: the top nodes under IN.A and IN.B each hold "MOV UP, DOWN", the middle-row node on the left holds "MOV UP, ACC" and "MOV ACC, RIGHT" twice, and the node beside it holds a START program with "SAV", "SUB LEFT", "JGZ B", "SWP" and a B section

One node fewer

The commentary wonders how the friend used fewer nodes, then moves the code up into the two nodes under IN.A and IN.B, with two "MOV UP, DOWN" nodes carrying the result to OUT. It works on the first try: 155 cycles, 4 nodes, 18 instructions, one cycle under the friend's 156.

The Sequence Generator editor with the shorter version: the code now sits in the top nodes under IN.A and IN.B, the IN.A node holding "MOV UP, ACC" and "MOV ACC, RIGHT" twice and the IN.B node a START program with "SUB LEFT" and "JLZ B", while two nodes below hold "MOV UP, DOWN" down to OUT

Where it ends

Back on the segment map, Sequence Generator reads NOMINAL beside the segments passed before it, with Sequence Counter next in the row. The commentary says the next episode will carry on through the programs, and the video cuts to the end card.