This program handles an interrupt which is generated when the button on the rabbit’s head is pressed. It flashes some lights all the time, to show that the program hasn’t locked-up, and it flashes another light when the button is pressed.
ID 0x7ffffffd
TRANSITION IMMEDIATE
# 0: black, 1: red, 2: green, 3: yellow, 4: blue, 5: purple, 6: cyan, 7: white
# Set the LEDs to black
LD R2,5
ledreset:
DEC R2
LD R0,0
LD R1,0
BSR @setanlednow
TST R2
BEQ @ledreset1
BRA @ledreset
ledreset1:
# Register the interrupt handler
LD R0,0
INPUT R0,@int_handler
LD R0,1
LD R1,255
LD R2,0
BSR @setanlednow
mainloop:
LD R0,1
LD R1,255
LD R2,0
BSR @setanlednow
WAIT 10
LD R0,4
LD R1,255
LD R2,0
BSR @setanlednow
WAIT 10
BRA @mainloop
int_handler:
PUSH R2,R1,R0
# Set an LED
LD R0,7
LD R1,255
LD R2,2
BSR @setanlednow
WAIT 5
LD R0,5
LD R1,255
LD R2,2
BSR @setanlednow
PULL R2,R1,R0
RTI
# Call "BSR @setanlednow" with the palette colour
# in R0, the intensity in R1, and the LED number
# in R2
setanlednow:
PUSH R7,R6,R5,R4,R3,R2,R1,R0
LD R7,0
LD R6,R2
LD R5,R1
LD R4,R0
PALETTE R4,R5
LED R6,R7
PULL R7,R6,R5,R4,R3,R2,R1,R0
RTS