Syscall 2: Firmware, home

BenchChapter 11: Capstones

B91JOLT

The task

P0 reads a knob on CH1 with a small ripple on top. Sample it on each tick of P2.

Light the LED on P1 for one tick whenever the reading moved more than 10 since the last tick.

Up or down, both count. B starts at 0, so the first tick counts too.

The board

The chip of JOLTChip u1 with 3 ports: P0 analog in, reaching V1, CH1; P1 digital out, reaching R1, D1, CH2; P2 timer 20 cycles.u1CHIP SC-2P0ANALOG INV1, CH1P1DIGITAL OUTR1, D1, CH2P2TIMER 20 CYCLES
The chip's ports, each with its kind and the parts its signal reaches. Cyan reads, lemon writes. On a narrow screen, scroll the board sideways to see all of it.
Sources
V1 3.5 V, V2 2 V square at 12.5 Hz, V3 1 V square at 6.25 Hz, and V4 0.25 V square at 250 Hz
Resistors
R1 330 Ω
LEDs
D1 white
Probes
CH1 and CH2

Key idea

XCH puts the new reading in B for next time and brings the old one into A.

Hints

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

Hint 1Show

Old minus new, with the sign flipped when it is not positive, is the size of the move.

Hint 2Show

The size minus 10, if positive, can light the LED as it is.

Solution

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

A change detector on the size of each step.

u1SC-2 standard

L: IN P2
IN P0
XCH
SUB B
JG P
NEG
P: SUB 10
JG H
MOV A, 0
H: OUT P1
CYCLES
748
at par
ENERGY
1496
at par
NODES
1
at par
INSTRUCTIONS
10
at par