Syscall 2: Firmware, home

BenchChapter 5: Half duplex

B28TOLERANCE

The task

P0 reads a slow triangle wave as a percent of the 5 volt supply.

Light the LED on P1 while the input is from 2 to 3 volts, and keep it dark outside.

The board

The chip of TOLERANCEChip u1 with 2 ports: P0 analog in, reaching V1, CH1; P1 digital out, reaching R1, D1, CH2.u1CHIP SC-2P0ANALOG INV1, CH1P1DIGITAL OUTR1, D1, CH2
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 2.5 V triangle at 25 Hz and V2 2.5 V
Resistors
R1 330 Ω
LEDs
D1 green
Probes
CH1 and CH2

Key idea

2 and 3 volts read as 40 and 60 percent.

Hints

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

Hint 1Show

Two tests in a row: first rule out readings under 40, then readings over 60.

Hint 2Show

After SUB 40, JL catches the low ones. A further SUB 20 and JG catch the high ones.

Solution

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

The LED lights inside a window from 2 to 3 volts.

u1SC-2 standard

L: IN P0
SUB 40
JL NO
SUB 20
JG NO
MOV A, 1
OUT P1
JMP L
NO: MOV A, 0
OUT P1
CYCLES
800
at par
ENERGY
1600
at par
NODES
1
at par
INSTRUCTIONS
10
at par