SCOPE Solution
CEILING
SCOPE ACT 1

Prerequisites
Unlocks
sc_a1_08_ceiling locked
Par power1325
Par lines9
Par chips1
Objective
A rising sawtooth 0..127, capped by a compare, then a snap back to 0.
Board Data
- Window: 264
- Pins: p0 OUT
- Channels: p0 ANALOG label=CH1_p0_DAC
- Peripherals: DAC data=p0 label=DAC_on_p0
Firmware Solution
; CEILING reference: a rising sawtooth 0,1,...,127 that hits a CEILING at 128 and
; snaps back to 0. Unlike RAMP it does not ride the 256 wrap; r0 is COMPARED to the
; ceiling each tick and the loop resets when it reaches it. Teaches cmp + a conditional
; jump (jl): jump back to keep climbing while below the ceiling, else reset to 0.
top:
mov r0, 0
loop:
out p0, r0 ; draw the current level
slp 1 ; one tick per level
inc r0 ; next level
cmp r0, 128 ; reached the ceiling?
jl loop ; below 128 -> keep climbing
jmp top ; at the ceiling -> reset to 0
Board Definition
# CEILING. ACT 1, analog. A rising sawtooth that does NOT ride the automatic 256 wrap
# like RAMP: it climbs to a CEILING at 128 and snaps back to 0. The level is COMPARED
# to the ceiling each tick and reset when it reaches it, so this board teaches cmp and
# a conditional jump (the first SCOPE board with real branching). Reference is
# sc_a1_08_ceiling.asm.
# TITLE CEILING
# OBJECTIVE A rising sawtooth 0..127, capped by a compare, then a snap back to 0.
ID sc_a1_08_ceiling
WINDOW 264
DIR p0 OUT
PERIPH DAC data=p0 label=DAC_on_p0
CHAN p0 ANALOG label=CH1_p0_DAC
PAR power=1325 lines=9 chips=1