Syscall 2: Firmware, home

BenchChapter 7: Frames and loops

B44LADDER

The task

R1, R2, and R3 add P0 and P1 into one voltage on CH1.

P0 alone gives 1 volt, P1 alone gives 2, and both give 3.

On each tick of P2, climb one volt, and after 3 volts drop back to 0.

The board

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

Key idea

The count of ticks MOD 4 is the number of volts.

Hints

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

Hint 1Show

P0 is the ones bit of that number and P1 the twos bit.

Hint 2Show

MOD 2 gives the ones bit. DIV 2 gives the twos bit of a number under 4.

Solution

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

Two pins add into four levels: 0, 1, 2, and 3 volts.

u1SC-2 standard

IN P2
MOD 4
MOV B, A
MOD 2
OUT P0
MOV A, B
DIV 2
OUT P1
CYCLES
153
at par
ENERGY
306
at par
NODES
1
at par
INSTRUCTIONS
8
at par