Syscall 2: Firmware, home

SignalChapter 9: Special nodes

66WIDE WINDOW

The task

P must receive the sum of the last four X values, with zeros before the first one.

win is an SC-4, a quad core: it has four registers, A, B, C, and D.

Write XCH A, B to swap. On an SC-4 also XCH A, C, XCH A, D, or even XCH B, C.

The board

The board of WIDE WINDOW1 core: win. Inputs X; outputs P.winSC-4 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

The SC-4: registers C and D, every instruction 1 cycle at 3 energy; three swaps shift a history down B, C, and D.

Hints

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

Hint 1Show

An SC-4 has C and D as well as B. Name them in XCH and read them like B: ADD C, MOV A, D.

Hint 2Show

Three swaps in a row move every value one register along, and A ends with the oldest.

Hint 3Show

ADD B, ADD C, and ADD D read the registers without changing them.

Solution

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

winSC-4 quad

IN P0
XCH A, B
XCH A, C
XCH A, D
ADD B
ADD C
ADD D
OUT P1
CYCLES
352
at par
ENERGY
2808
at par
NODES
1
at par
INSTRUCTIONS
8
at par

Another way: Swap up

A second program that also passes, and matches par on every benchmark.

The swaps run from D up to B instead. The registers rotate rather than shift, but they still hold the last three values, and a sum does not care in which order.

winSC-4 quad

IN P0
XCH A, D
XCH A, C
XCH A, B
ADD B
ADD C
ADD D
OUT P1
CYCLES
352
at par
ENERGY
2808
at par
NODES
1
at par
INSTRUCTIONS
8
at par