Syscall 2: Firmware, home

BenchChapter 9: Special nodes

B68TRACKER

The task

P0 reads a target on CH1. P1 charges C1 through R1, and P2 reads C1 back.

On each tick of P3, raise P1 while C1 is below the target and lower it otherwise.

CH2 follows CH1.

The board

The chip of TRACKERChip u1 with 4 ports: P0 analog in, reaching V1, CH1; P1 digital out, reaching R1, C1, CH2; P2 analog in, reaching R1, C1, CH2; P3 timer 12 cycles.u1CHIP SC-2P0ANALOG INV1, CH1P1DIGITAL OUTR1, C1, CH2P2ANALOG INR1, C1, CH2P3TIMER 12 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 1.2 V triangle at 10 Hz and V2 2.5 V
Resistors
R1 22 kΩ
Capacitors
C1 1 µF
Probes
CH1 and CH2

Key idea

Subtract C1's reading from the target: a positive result means C1 needs more charge.

Hints

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

Hint 1Show

Any nonzero value drives a digital pin high, so a positive difference can go straight out.

Hint 2Show

IN P3, IN P2, MOV B, A, IN P0, SUB B, then JG past a MOV A, 0 to OUT P1.

Solution

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

Charge while C1 is below the target.

u1SC-2 standard

IN P3
IN P2
MOV B, A
IN P0
SUB B
JG H
MOV A, 0
H: OUT P1
CYCLES
618
at par
ENERGY
1236
at par
NODES
1
at par
INSTRUCTIONS
8
at par