B89UART
The task
Send the knob's reading out of P1 as serial, one bit per tick of P2, in frames of 16 ticks.
A frame starts where the tick count from IN P2, MOD 16, is 0. Send a 0 there: the start bit.
Then send the reading's 7 bits, lowest first, and hold P1 high for the rest of the frame.
Read the knob on the start tick. The line rests high, a 1 is high, and a 0 is low.
The board
- Sources
- V1 3.5 V, V2 2 V square at 12.5 Hz, and V3 1 V square at 6.25 Hz
- Resistors
- R1 330 Ω
- LEDs
- D1 yellow
- Probes
- CH1 and CH2
Key idea
IN P2 returns the running tick count, so MOD 16 tells you where you are in the frame.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
Keep 127 minus the reading in B: shifted out, it gives each bit flipped, then 0 once spent.
Hint 2Show
A flipped bit minus 1 is nonzero for a 1 and 0 for a 0, and a spent B then reads high.
Solution
Reveal the Full SolutionThe complete program for UART. 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.
Start bit, seven data bits, and a line that rests high.
u1SC-2 standard
L: IN P2
MOD 16
JZ ST
MOV A, B
DIV 2
XCH
MOD 2
SUB 1
OUT P1
JMP L
ST: OUT P1
IN P0
NEG
ADD 127
MOV B, A- CYCLES
- 783
- at par
- ENERGY
- 1566
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 15
- at par