Syscall 2: Firmware, home

ShuffleChapter 12: Shared buses

S50CROSSTALK

The task

The bus handshake, every piece swapped about. Swaps stay inside a core.

X arrives at a and Y at c. P on a must receive X plus Y.

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

The board

The board of CROSSTALK3 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

Par is 11 swaps. Core a needs 2 instruction swaps and 2 operand swaps; core b needs 2 instruction swaps and 2 operand swaps; core c needs 2 instruction swaps and 1 operand swap. 8 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

Each value goes out on the bus twice, since two cores need it.

Hint 2Show

c speaks first while a listens, then a answers while c listens.

Hint 3Show

A core keeps its own value in B while it reads the other one.

Solution

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

OUT P0
MOV P2, A
IN B
IN B
ADD B
MOV A, P1
OUT P1
OUT P1

bSC-2 standard

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

cSC-2 standard

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

11 swaps back

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

  1. In core a, swap the operand P2 on line 2 with B on line 5.
  2. In core a, swap the operand B on line 3 with P1 on line 6.
  3. In core a, swap the instruction OUT on line 1 with IN on line 4.
  4. In core a, swap the instruction OUT on line 4 with ADD on line 5.
  5. In core b, swap the operand B on line 2 with A on line 3.
  6. In core b, swap the operand B on line 3 with P0 on line 4.
  7. In core b, swap the instruction OUT on line 3 with IN on line 4.
  8. In core b, swap the instruction OUT on line 4 with MUL on line 5.
  9. In core c, swap the operand P2 on line 6 with B on line 7.
  10. In core c, swap the instruction OUT on line 1 with IN on line 7.
  11. In core c, swap the instruction SUB on line 2 with OUT on line 6.

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
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
SWAPS
11
at par