An event handling routine for the 2TP-VME in OCCAM should look like:
-- If VME interrupts can be present at transputer boot time, initialize
-- the 2TP-VME by acknowledging these interrupts outside any event process:
intl.flag := (statusregister0 /\ #01)
WHILE (intl.flag > 0)
SEQ
... acknowledge the VME interrupt
-- reset intl.flag in statusregister0:
statusregister0 := intl.flag
intl.flag := (statusregister0 /\ #01)
.
.
-- Here's the actual event process:
WHILE TRUE
event ? any
SEQ
event.flags := (statusregister0 /\ #3F)
WHILE (event.flags > 0)
SEQ
IF
(event.flags /\ priority1.flag) > 0
-- This event has highest priority
SEQ
-- reset priority1.flag in statusregister0:
statusregister0 := priority1.flag
... handle the event
(event.flags /\ priority2.flag) > 0
-- This event has second highest priority
SEQ
-- reset priority2.flag in statusregister0:
statusregister0 := priority2.flag
... handle the event
.
.
.
(event.flags /\ priority.lowest.flag) > 0
-- This event has lowest priority
SEQ
-- reset priority.lowest.flag in statusregister0:
statusregister0 := priority.lowest.flag
... handle the event
TRUE
SKIP
event.flags := (statusregister0 /\ #3F)