Syscall 2: Firmware, home

ShuffleChapter 5: Half duplex

S15LOOSE BULB

The task

The blink program is all here, swapped about. Put it back.

Blink the LED on P0: on for one tick of P1, off for the next.

The board

The chip of LOOSE BULBChip u1 with 2 ports: P0 digital out, reaching R1, D1, CH1; P1 timer 20 cycles.u1CHIP SC-2P0DIGITAL OUTR1, D1, CH1P1TIMER 20 CYCLES
The chip's ports, each with its kind and the parts its signal reaches. Cyan reads, lemon writes.
Resistors
R1 330 Ω
LEDs
D1 red
Probes
CH1

Key idea

Par is 3 swaps. Core u1 needs 1 instruction swap and 2 operand swaps. Every one of them trades two tiles that hold each other's places, so each swap mends two.

Hints

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

Hint 1Show

IN P1 sleeps until the timer ticks. Each change waits for a tick of its own.

Hint 2Show

MOV A, 1 then OUT P0 lights the LED. MOV A, 0 then OUT P0 puts it out.

Hint 3Show

Each swap compiles at once, and the circuit runs whatever you have.

Solution

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

IN P1
MOV A, 0
IN P1
OUT P0
MOV A, 1
OUT P0

3 swaps back

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

  1. In core u1, swap the operand 0 on line 2 with 1 on line 5.
  2. In core u1, swap the operand P1 on line 3 with P0 on line 4.
  3. In core u1, swap the instruction IN on line 3 with OUT on line 4.

The finished program

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

u1SC-2 standard

IN P1
MOV A, 1
OUT P0
IN P1
MOV A, 0
OUT P0
CYCLES
28
at par
ENERGY
56
at par
NODES
1
at par
INSTRUCTIONS
6
at par
SWAPS
3
at par