Syscall 2: Firmware, home

BenchChapter 5: Half duplex

B27POLARITY

The task

V1 and V2 put a sine wave on P0, swinging 2 volts either side of 2.5 volts.

Light the red LED on P1 while the input is above 2.5 volts,

and the green LED on P2 the rest of the time.

The board

The chip of POLARITYChip u1 with 3 ports: P0 analog in, reaching V1, CH1; P1 digital out, reaching R1, D1, CH2; P2 digital out, reaching R2, D2, CH3.u1CHIP SC-2P0ANALOG INV1, CH1P1DIGITAL OUTR1, D1, CH2P2DIGITAL OUTR2, D2, 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 2 V sine at 50 Hz and V2 2.5 V
Resistors
R1 330 Ω and R2 330 Ω
LEDs
D1 red and D2 green
Probes
CH1, CH2, and CH3

Key idea

The middle, 2.5 volts, reads as 50 percent.

Hints

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

Hint 1Show

Each LED keeps its level until the next OUT on its pin, so set both on every pass.

Hint 2Show

After SUB 50, JG picks the red side. The other path lights green.

Solution

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

Red above the middle, green below.

u1SC-2 standard

L: IN P0
SUB 50
JG UP
MOV A, 0
OUT P1
MOV A, 1
OUT P2
JMP L
UP: OUT P1
MOV A, 0
OUT P2
CYCLES
400
at par
ENERGY
800
at par
NODES
1
at par
INSTRUCTIONS
11
at par