Syscall 2: Firmware, home

BenchChapter 8: Scarcity

B61BICOLOR

The task

P0 and P1 drive two LEDs back to back. Current flows from the high pin to the low one.

Red lights while P0 is high and P1 low, green the other way round, neither while both are low.

P2 ticks every 20 cycles. Show red for one tick, green for two, then dark for one.

The board

The chip of BICOLORChip u1 with 3 ports: P0 digital out, reaching R1, D1, D2, CH1; P1 digital out, reaching R2, D1, D2, CH1; P2 timer 20 cycles.u1CHIP SC-2P0DIGITAL OUTR1, D1, D2, CH1P1DIGITAL OUTR2, D1, D2, CH1P2TIMER 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.
Resistors
R1 220 Ω, R3 10 kΩ, and R2 220 Ω
LEDs
D1 red and D2 green
Probes
CH1

Key idea

CH1 reads about 3.3 volts for red and 1.4 for green; 0 with both pins low, 5 with both high.

Hints

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

Hint 1Show

Every change sets both pins: lower one before you raise the other, so both are never high.

Hint 2Show

Sleep, raise P0, sleep, lower P0 and raise P1, sleep twice, lower P1.

Solution

Reveal the Full SolutionThe complete program for BICOLOR. 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, green, green, dark.

u1SC-2 standard

IN P2
MOV A, 1
OUT P0
IN P2
MOV A, 0
OUT P0
MOV A, 1
OUT P1
IN P2
IN P2
MOV A, 0
OUT P1
CYCLES
58
at par
ENERGY
116
at par
NODES
1
at par
INSTRUCTIONS
12
at par