Syscall 2: Firmware, home

SignalChapter 5: Half duplex

30METER

The task

The locked meter adds each value it gets, writes its total to P, and sends the total back.

P must show the running total of X, back to 0 after each 0.

The board

The board of METER2 cores: feed and m. Locked: m. Inputs X; outputs P.feedSC-2 15 LINESmLOCKEDMOV B, AIN P0ADD BOUT P1OUT P0P0P1P0P1XP
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

Cancel a locked adder's total by sending it back negated; read each reply before the next send.

Hints

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

Hint 1Show

The meter can only add. To bring its total to 0, send the total with its sign flipped.

Hint 2Show

Keep the last total the meter sent back in B.

Hint 3Show

Read the meter's answer before you send the next value.

Solution

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

feedSC-2 standard

T: IN P0
JZ N
OUT P1
IN P1
MOV B, A
JMP T
N: XCH A, B
NEG
OUT P1
IN P1
CYCLES
426
at par
ENERGY
1386
at par
NODES
1
at par
INSTRUCTIONS
10
at par