Syscall 2: Firmware, home

BenchChapter 2: Workshop

B01BLINK

The task

P0 drives the LED through R1. OUT P0 lights it with any value but 0.

P1 is the chip's timer. IN P1 sleeps until its next tick.

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

The board

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

The scope shows the target band on CH1. Keep your trace inside it.

Hints

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

Hint 1Show

The timer ticks every 20 cycles. A chip asleep on IN P1 spends no energy.

Hint 2Show

Sleep on P1, write 1 to P0, sleep again, write 0.

Solution

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

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

Another way: Mod

A second program that also passes, and beats par on INSTRUCTIONS.

Three lines: the tick count's parity is the LED.

u1SC-2 standard

IN P1
MOD 2
OUT P0
CYCLES
28
at par
ENERGY
56
at par
NODES
1
at par
INSTRUCTIONS
3
under par