Syscall 2: Firmware, home

ShuffleChapter 4: Stars and hubs

S11KEPT COPY

The task

The program is here, with its pieces swapped. Put them back.

Every value from X must reach P doubled. MOV B, A keeps a copy of A.

The board

The board of KEPT COPY1 core: a. Inputs X; outputs P.aSC-2 15 LINESP0P1XP
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 2 swaps. Core a needs 2 operand swaps. One of them trades two tiles that hold each other's places; look for it 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

MOV B, A copies A into B without changing A. ADD B adds that copy.

Hint 2Show

IN replaces A, so the copy is taken after the read and before the add.

Hint 3Show

OUT sends A as it stands. The double has to be sitting in A by then.

Solution

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

aSC-2 standard

IN A
MOV P0, B
ADD B
OUT P1

2 swaps back

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

  1. In core a, swap the operand A on line 1 with P0 on line 2.
  2. In core a, swap the operand A on line 2 with B on line 2.

The finished program

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

aSC-2 standard

IN P0
MOV B, A
ADD B
OUT P1
CYCLES
196
at par
ENERGY
936
at par
NODES
1
at par
INSTRUCTIONS
4
at par
SWAPS
2
at par