Syscall 2: Firmware, home

SignalChapter 12: Shared buses

92LEFT FIRST

The task

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

P, on b, must receive X minus Y.

The board

The board of LEFT FIRST3 cores: a, b, and c. Inputs X and Y; outputs P. 1 shared bus.aSC-2 15 LINESbSC-2 15 LINEScSC-2 15 LINESP0P1P0P1P0P1YXP
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 writers: IN takes the end farther left first, so b reads Y before X.

Hints

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

Hint 1Show

When a and c have both written, IN takes a's value first: the one farther left on the bus.

Hint 2Show

MOV B, A keeps the first value in B while b reads the second.

Hint 3Show

SUB B takes B from A, so the value read first is the one taken away.

Solution

Reveal the Full SolutionThe complete program for LEFT FIRST. 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

bSC-2 standard

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

cSC-2 standard

IN P0
OUT P1
CYCLES
237
at par
ENERGY
2106
at par
NODES
3
at par
INSTRUCTIONS
9
at par