Syscall 2: Firmware, home

BenchChapter 5: Half duplex

B33BEACON

The task

A beacon flashes twice, then rests. P1 ticks every 10 cycles and P0 drives the lamp.

Light it on the first and third tick of every twelve, and keep it dark on the other ten.

The board

The chip of BEACONChip u1 with 2 ports: P0 digital out, reaching R1, D1, CH1; P1 timer 10 cycles.u1CHIP SC-2P0DIGITAL OUTR1, D1, CH1P1TIMER 10 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

IN P1 counts the ticks. MOD 12 gives the place in the pattern, 0 to 11.

Hints

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

Hint 1Show

Places 1 and 3 light the lamp. They are the odd places below 5.

Hint 2Show

Rule out the places from 5 up first, then MOD 2 picks the odd ones.

Solution

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

Two flashes, then a long rest.

u1SC-2 standard

L: IN P1
MOD 12
SUB 4
JG OFF
ADD 4
MOD 2
OUT P0
JMP L
OFF: MOV A, 0
OUT P0
CYCLES
321
at par
ENERGY
642
at par
NODES
1
at par
INSTRUCTIONS
10
at par