Syscall 2: Firmware, home

SignalChapter 12: Shared buses

99DOUBLE DECK

The task

a reads X, and c reads Y. b sits on both buses.

P, on d, must receive the larger of X and Y, and Q, on e, the smaller.

The board

The board of DOUBLE DECK5 cores: a, d, b, c, and e. Inputs X and Y; outputs P and Q. 2 shared buses.aSC-2 15 LINESdSC-2 15 LINESbSC-2 15 LINEScSC-2 15 LINESeSC-2 15 LINESP0P1P0P1P0P1P0P1P0P1XYPQ
The board as the puzzle screen lays it out. Cyan pins read, lemon pins write, violet pins go both ways. On a narrow screen, scroll the board sideways to see all of it.

Key idea

Two buses: b reads X and Y on one and writes the larger, then the smaller, on the other, where d must rest.

Hints

Each hint goes a step further than the one before. Open them one at a time.

Hint 1Show

b reads X before Y: when both are waiting, a's goes first, as a is farther left.

Hint 2Show

On the lower bus, d is farther left than e, so d takes whatever b writes first.

Hint 3Show

Once d has its value, it must stay off the bus until e has taken the other.

Solution

Reveal the Full SolutionThe complete program for DOUBLE DECK. Open it only when you want the answer.

The reference program

The game's own solution. It passes every test and scores exactly par on every benchmark.

aSC-2 standard

IN P0
OUT P1

dSC-2 standard

IN P0
OUT P1
NOP

bSC-2 standard

IN P0
MOV B, A
IN P0
SUB B
JG L
ADD B
XCH A, B
JMP O
L: ADD B
O: OUT P1
XCH A, B
OUT P1

cSC-2 standard

IN P0
OUT P1

eSC-2 standard

IN P0
OUT P1
CYCLES
476
at par
ENERGY
4440
at par
NODES
5
at par
INSTRUCTIONS
21
at par