          bin
start     dc.w   $FE00
hours     dc.w   0
minutes   dc.w   0
seconds   dc.w   0
alhrs     dc.w   25
almins    dc.w   0
alsecs    dc.w   0
tsecs     dc.w   0
onoff     dc.w   0

return    jmp    0

update    movem.l A0/A1/A2,-(SP)
          lea    hours,A0

* update tsec first
          addq.w #1,12(A0)
          cmpi.w #10,12(A0)
          blt    nogo

* if = 10 then reset and update seconds
          clr.w  12(A0)
          addq.w #1,4(A0)
          cmpi.w #60,4(A0)
          blt    skip

* if = 60 then reset and update minutes
          clr.w  4(A0)
          addq.w #1,2(A0)
          cmpi.w #60,2(A0)
          blt    skip

* if = 60 then reset and update hours
          clr.w  2(A0)
          addq.w #1,(A0)
          cmpi.w #24,(A0)
          blt    skip

* if = 24 then reset
          clr.w  (A0)

skip      cmpi.w #0,14(A0)
          beq    nobell

* sound BELL character, control acia myself
loop1     btst   #1,$4000C1
          beq    loop1
          move.b #7,$4000C3
          addq.w #1,14(A0)
          cmpi.w #11,14(A0)
          bne    nobell

* disable alarm cos 10 seconds passed, set new impossible alarm time
          clr.w  14(A0)
          move.w #25,6(A0)

* test hours with alhrs, minutes with almin, seconds with alsecs
nobell    lea    alhrs,A2
          lea    hours,A1
          cmpm.w (A1)+,(A2)+
          bne    nogo
          cmpm.w (A1)+,(A2)+
          bne    nogo
          cmpm.w (A1)+,(A2)+
          bne    nogo
* if all equal then set flag to sound alarm
          move.w #1,14(A0)

* restore registers and return
nogo      movem.l (SP)+,A0/A1/A2
          bra    return

* these branch instructions are required so that the IMP control
* program knows where to set interrupt vectors, etc
          bra.w  return
          bra.w  update
          end
