/ 1st interrupt driven 
/ demonstration program:
/
/  it uses the interrupt mechanism
/ to monitor "clock ticks" while it
/ performs some computations.
/
/ (the computations involve a multiplication
/ done by repeated addition --- see other examples
/ for proper shift and add multiply code)
*0
        0 / for storing pc on interrupt
        jmp i pints / jump to interrupt handler
pints,ints
accsav,0 /somewhere to store acc
lnksav,0 /somwhere to store link
*20
ticks,0 /counter for clock ticks
*200
        cla
        dca ticks
        clkt /start the clock
        ion / enable interrupts
/ now start the multiplies, unsigned
/ small values for a & b
/ a*b = (b+b+b+ ... ) then necessary number of times
/(its assumed that product will fit in 12bits 
        cla
        tad a
        cia 
        dca cntr
        dca prdct
loop,tad  prdct
        tad b
        dca prdct
        isz cntr
        jmp loop
/ finished, stop the clock
        clkt
/ disable interrupts
        iof
        hlt
/ - - - - - -
a, 0076
b,0017
cntr,0
prdct,0
/ - - - - - -
*400
/ interrupt handler
/ - - - - save state of calculation - - -
ints,dca accsav /save acc
        ral
        dca lnksav /save link
/ - - - - identify device - - - -
        clksf / was it clock
        skp
        jmp clksrv
/ - - - - unknown device, best stop
        hlt
/ - - - - - return from interrupt
xit,cla cll
        tad lnksav
        rar
        tad accsav
        ion
        jmp i 0
/ - - - - - - - -device handlers
clksrv,clkcf /clear flag
        isz ticks /update count
        nop
        jmp xit
$
