Syscall 2: Firmware, home

SignalChapter 9: Special nodes

73ENCODER

The task

P must receive a code for each X sample: 1 if X is at or above the level, -1 if below.

The level and its step follow SLOPE, from a level of 0 and a step of 1.

lv is an SC-2D, with slow jumps, and st is an SC-4, with registers C and D.

The board

The board of ENCODER3 cores: lv, cmp, and st. Inputs X; outputs P.lvSC-2D 10 LINEScmpSC-2 15 LINESstSC-4 15 LINESP0P1P2P0P1P2P0P1XP
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

Feedback: the encoder runs a copy of SLOPE's decoder to know the level the receiver will hear.

Hints

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

Hint 1Show

An encoder must know what the receiver will hear, so it runs a copy of the decoder.

Hint 2Show

As in SLOPE, three matching codes in a row double the step, and any other code makes it 1.

Hint 3Show

lv keeps the level and sends the gap first, cmp makes the code, and st makes the step.

Solution

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

lvSC-2D signal processor

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

cmpSC-2 standard

IN P0
JL LO
MOV A, 1
JMP GO
LO: MOV A, -1
GO: OUT P2
OUT P1

stSC-4 quad

IN P0
XCH A, C
XCH A, D
ADD D
SUB C
SUB C
JNZ ONE
MOV A, B
ADD B
JMP GO
ONE: MOV A, 1
GO: MOV B, A
MUL C
OUT P1
CYCLES
876
at par
ENERGY
6757
at par
NODES
3
at par
INSTRUCTIONS
27
at par