Syscall 2: Firmware, home

ShuffleChapter 3: Chains and rings

S04LOOSE STEPS

The task

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

Build a staircase on CH1: five steps from 0 to 5 volts, then start over.

Climb one step on each tick of P1. P0 is a PWM pin into R1 and C1.

The board

The chip of LOOSE STEPSChip u1 with 2 ports: P0 pwm out, reaching R1, C1, CH1; P1 timer 40 cycles.u1CHIP SC-2P0PWM OUTR1, C1, CH1P1TIMER 40 CYCLES
The chip's ports, each with its kind and the parts its signal reaches. Cyan reads, lemon writes.
Resistors
R1 1 kΩ
Capacitors
C1 1 µF
Probes
CH1

Key idea

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

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

Hint 2Show

Each step is a quarter of the supply: 25 percent more duty.

Hint 3Show

MOV B, A copies A into B, and MOV A, B copies it back, so B can hold the duty between ticks.

Solution

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

MOV A, B
IN P0
JNZ 25
MOV B, A
SUB A
ADD W
MOV B, 125
W: OUT P1

3 swaps back

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

  1. In core u1, swap the operand A on line 5 with 125 on line 7.
  2. In core u1, swap the instruction IN on line 2 with OUT on line 8.
  3. In core u1, swap the instruction JNZ on line 3 with ADD on line 6.

The finished program

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

u1SC-2 standard

MOV A, B
OUT P0
ADD 25
MOV B, A
SUB 125
JNZ W
MOV B, A
W: IN P1
CYCLES
72
at par
ENERGY
144
at par
NODES
1
at par
INSTRUCTIONS
8
at par
SWAPS
3
at par