Syscall 2: Firmware, home

BenchChapter 4: Stars and hubs

B13LANDING

The task

P0 is a PWM pin into R1 and C1. Duty is a percent of the 5 volt supply.

P1 ticks every 40 cycles. After the opening rest, CH1 steps down.

Full, then three quarters, half, a quarter, and off, then full again.

The board

The chip of LANDINGChip 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

MOV B, A keeps the duty across the sleep. MOV A, B brings it back.

Hints

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

Hint 1Show

SUB 25 drops one step. At 0 the next duty is 100, not a negative step.

Hint 2Show

JZ takes the reset. Any other result keeps the subtracted duty.

Solution

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

Rest, then step down from full to off.

u1SC-2 standard

MOV A, B
OUT P0
JZ RESET
SUB 25
JMP SAVE
RESET: MOV A, 100
SAVE: MOV B, A
IN P1
CYCLES
68
at par
ENERGY
136
at par
NODES
1
at par
INSTRUCTIONS
8
at par