Syscall 2: Firmware, home

BenchChapter 6: Trees

B36BIT BANG

The task

P0 is a plain digital pin this time, not PWM, and R1 and C1 smooth what it puts out.

Hold CH1 at 1.5 volts anyway: keep P0 high for 3 cycles out of every 10.

Every instruction takes one cycle.

The board

The chip of BIT BANGChip u1 with 1 ports: P0 digital out, reaching R1, C1, CH1.u1CHIP SC-2P0DIGITAL OUTR1, C1, CH1
The chip's ports, each with its kind and the parts its signal reaches. Cyan reads, lemon writes.
Resistors
R1 1 kΩ
Capacitors
C1 10 µF
Probes
CH1

Key idea

OUT sets the pin at the end of its cycle, and the pin keeps that level until the next OUT.

Hints

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

Hint 1Show

Three cycles from the OUT that raises P0 to the one that drops it, then seven until the next.

Hint 2Show

NOP spends one cycle and does nothing else.

Solution

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

A duty of 30 percent by hand on a plain pin.

u1SC-2 standard

MOV A, 1
OUT P0
MOV A, 0
NOP
OUT P0
NOP
NOP
NOP
NOP
NOP
CYCLES
800
at par
ENERGY
1600
at par
NODES
1
at par
INSTRUCTIONS
10
at par

Another way: Loop

A second program that also passes, and beats par on INSTRUCTIONS.

The seven low cycles as a short countdown.

u1SC-2 standard

MOV A, 1
OUT P0
MOV A, 0
NOP
OUT P0
MOV A, 2
W: SUB 1
JNZ W
CYCLES
800
at par
ENERGY
1600
at par
NODES
1
at par
INSTRUCTIONS
8
under par