Syscall 2: Firmware, home

ShuffleChapter 6: Trees

S19EVERY OTHER

The task

The divider, swapped about. Swap it back.

Toggle the LED on P1 at every rising edge of the square wave on P0.

It blinks at half the rate of the input.

The board

The chip of EVERY OTHERChip u1 with 2 ports: P0 digital in, reaching V1, CH1; P1 digital out, reaching R1, D1, CH2.u1CHIP SC-2P0DIGITAL INV1, CH1P1DIGITAL OUTR1, D1, CH2
The chip's ports, each with its kind and the parts its signal reaches. Cyan reads, lemon writes. On a narrow screen, scroll the board sideways to see all of it.
Sources
V1 5 V square at 250 Hz
Resistors
R1 330 Ω
LEDs
D1 green
Probes
CH1 and CH2

Key idea

Par is 4 swaps. Core u1 needs 2 instruction swaps and 2 operand swaps. 3 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

Wait for the high with JZ, and after the toggle wait for the low with JNZ.

Hint 2Show

1 minus the LED's last state is its next state. B keeps the state.

Hint 3Show

MOV B, A keeps the new state before OUT sends it.

Solution

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

u1SC-2 standard

L: IN P0
JNZ L
MOV B, 1
IN P0
MOV B, A
OUT P1
H: SUB A
JZ H

4 swaps back

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

  1. In core u1, swap the operand B on line 3 with A on line 7.
  2. In core u1, swap the operand P0 on line 4 with B on line 7.
  3. In core u1, swap the instruction JNZ on line 2 with JZ on line 8.
  4. In core u1, swap the instruction IN on line 4 with SUB on line 7.

The finished program

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

u1SC-2 standard

L: IN P0
JZ L
MOV A, 1
SUB B
MOV B, A
OUT P1
H: IN P0
JNZ H
CYCLES
400
at par
ENERGY
800
at par
NODES
1
at par
INSTRUCTIONS
8
at par
SWAPS
4
at par