Syscall 2: Firmware, home

ShuffleChapter 5: Half duplex

S16WRONG NUMBER

The task

The operator's code is here, its pieces swapped. Put them back.

Each locked caller sends two values and waits for their sum.

The board

The board of WRONG NUMBER3 cores: c0, op, and c2. Locked: c0 and c2. Inputs X and Y; outputs P and Q.c0LOCKEDIN P0OUT P1IN P0OUT P1IN P1OUT P2opSC-2 15 LINESc2LOCKEDIN P0OUT P1IN P0OUT P1IN P1OUT P2P0P1P2P0P1P0P1P2XYPQ
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

Par is 3 swaps. Core op needs 2 instruction swaps and 1 operand swap. 2 of them trade two tiles that hold each other's places; look for those first, since one swap mends both.

Hints

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

Hint 1Show

IN ANY takes the first caller with a value waiting.

Hint 2Show

LAST is the pin ANY used, so IN LAST and OUT LAST stay with that caller.

Hint 3Show

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

Solution

Reveal the Full SolutionThe complete program for WRONG NUMBER. Open it only when you want the answer.

The board as dealt

This is the arrangement the game deals. Framed tiles are the ones out of place.

opSC-2 standard

OUT ANY
MOV B, A
IN LAST
IN LAST
ADD B

3 swaps back

Make these swaps in order. Lines are numbered from 1 in each core.

  1. In core op, swap the operand LAST on line 4 with B on line 5.
  2. In core op, swap the instruction OUT on line 1 with IN on line 4.
  3. In core op, swap the instruction OUT on line 4 with ADD on line 5.

The finished program

Every tile back in place: the reference solution, which scores exactly par on every benchmark.

opSC-2 standard

IN ANY
MOV B, A
IN LAST
ADD B
OUT LAST
CYCLES
126
at par
ENERGY
380
at par
NODES
1
at par
INSTRUCTIONS
5
at par
SWAPS
3
at par