Syscall 2: Firmware, home

SignalChapter 9: Special nodes

69ROTATE

The task

P must receive 3X minus 4Y, and Q 4X plus 3Y: the point X, Y turned and stretched.

u and v are SC-2D signal processors: 10 lines, and every jump takes 3 cycles.

Each core reads one stream, and each needs both values.

The board

The board of ROTATE2 cores: u and v. Inputs X and Y; outputs P and Q.uSC-2D 10 LINESvSC-2D 10 LINESP0P1P2P0P1P2XYPQ
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

MUL joins the kit: straight multiply and add on two SC-2Ds that share their inputs over one wire, one sending first.

Hints

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

Hint 1Show

MUL multiplies A by a number or a register: MUL 3 makes A three times as large.

Hint 2Show

Share the values over the wire. One core sends first and then reads; the other reads first.

Hint 3Show

Work out your own value's share before you read the other value, and keep it in B.

Solution

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

uSC-2D signal processor

IN P0
OUT P1
MUL 3
MOV B, A
IN P1
MUL -4
ADD B
OUT P2

vSC-2D signal processor

IN P1
MUL 4
MOV B, A
IN P0
OUT P1
MUL 3
ADD B
OUT P2
CYCLES
469
at par
ENERGY
3744
at par
NODES
2
at par
INSTRUCTIONS
16
at par

Another way: Late share

A second program that also passes, by a different road, at a cost on CYCLES, ENERGY, and INSTRUCTIONS.

Each core waits for the other value before it works out its own share, which costs an XCH on each side and a cycle on every point.

uSC-2D signal processor

IN P0
OUT P1
MOV B, A
IN P1
MUL -4
XCH A, B
MUL 3
ADD B
OUT P2

vSC-2D signal processor

IN P1
MOV B, A
IN P0
OUT P1
MUL 3
XCH A, B
MUL 4
ADD B
OUT P2
CYCLES
508
over par
ENERGY
4212
over par
NODES
2
at par
INSTRUCTIONS
18
over par