kontst   equ $8
prostot  equ $9
prestr   equ $d
iedg     equ %00000010
eici     equ %00010000
icf_f    equ %10000000


         org $fffe
         fdb start
         org $2000
st       rmb 1
st1      rmb 2
st2      rmb 2
raz      rmb 2
         org $fff6
         fdb tim_prek
         org $a000

start    lds #$3000
         cli
         clr st
         ldaa #%11110
         staa 1
         ldaa #iedg
         oraa #eici
         staa kontst

         wai

tim_prek ldaa kontst
         bita #icf_f
         beq motnja

         ldaa st
         bita #$1
         beq prvic

         clr st
         ldd prestr
         std st2

         subd st1
         std raz
         ldaa kontst
         oraa #iedg
         staa kontst
         rti

prvic    inc st
         ldd prestr
         std st1
         ldaa #eici
         staa kontst
motnja   rti
