Syscall 2: Firmware, home

SignalChapter 12: Shared buses

96HANDSHAKE

The task

a, b, and c share a bus. X arrives at a, and Y at c.

P on a must receive X plus Y, Q on c X minus Y, and R on b X times Y.

The board

The board of HANDSHAKE3 cores: a, b, and c. Inputs X and Y; outputs P, Q, and R. 1 shared bus.aSC-2 15 LINESbSC-2 15 LINEScSC-2 15 LINESP0P1P2P0P1P0P1P2XPRYQ
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

Each value is needed twice: one side speaks while the other listens, then they swap; all writing at once is HEAD ON.

Hints

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

Hint 1Show

Each value is needed by two cores, so each goes out on the bus twice.

Hint 2Show

If a and c both write first, b alone reads, and it takes a's value both times.

Hint 3Show

Let one side speak while the other listens, then swap.

Solution

Reveal the Full SolutionThe complete program for HANDSHAKE. 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
MOV B, A
IN P1
ADD B
OUT P2
MOV A, B
OUT P1
OUT P1

bSC-2 standard

IN P0
MOV B, A
IN P0
MUL B
OUT P1

cSC-2 standard

IN P0
OUT P1
OUT P1
MOV B, A
IN P1
SUB B
OUT P2
CYCLES
547
at par
ENERGY
4680
at par
NODES
3
at par
INSTRUCTIONS
20
at par