Syscall 2: Firmware, home

BenchChapter 5: Half duplex

B25EXCLUSIVE

The task

P0 and P1 read two square waves. Light the LED on P2 while exactly one of them is high.

When both are high or both are low, keep it dark.

The board

The chip of EXCLUSIVEChip u1 with 3 ports: P0 digital in, reaching V1, CH1; P1 digital in, reaching V2, CH2; P2 digital out, reaching R1, D1, CH3.u1CHIP SC-2P0DIGITAL INV1, CH1P1DIGITAL INV2, CH2P2DIGITAL OUTR1, D1, CH3
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 5 V square at 125 Hz and V2 5 V square at 200 Hz
Resistors
R1 330 Ω
LEDs
D1 yellow
Probes
CH1, CH2, and CH3

Key idea

MOV B, A keeps the first reading while you take the second.

Hints

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

Hint 1Show

The difference of two readings is 0 only when they match.

Hint 2Show

SUB B leaves 1 or minus 1 when they differ, and either one lights the LED.

Solution

Reveal the Full SolutionThe complete program for EXCLUSIVE. 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 while the inputs differ.

u1SC-2 standard

IN P0
MOV B, A
IN P1
SUB B
OUT P2
CYCLES
400
at par
ENERGY
800
at par
NODES
1
at par
INSTRUCTIONS
5
at par