2-1
Section
CPM2A/CPM2C Interrupt Functions
43
A problem can occur in the situation shown below because processing of the
ADD instruction could be interrupted between the 1st and 3rd operands and the
MOV instruction then executed in the interrupt program.
Main Program
Interrupt Program
ADD (30)
DM0000
#0001
DM0000
MOV (21)
#0010
DM0000
Flow of Processing
The processing that would occur when the ADD instruction above is interrupted
is illustrated below.
Contents of DM 0000 read (1234)
BCD add executed (1234 + 1 = 1235)
Processing interrupted
Interrupt generated
Data temporarily buffered
Add result (1235)
MOV executed
#0010 moved to DM 0000
Interrupt program ended
Processing continued
Add result (1235) written
ADD
instruction
DM0000
1234
0010
1235
Processing is interrupted before the result of the add operation can be written to
DM 0000 and the result is buffered. The interrupt program writes #0010 to
DM 0000, but this is immediately overwritten by the result of the add (1235) as
soon as execution of the interrupt program has been completed. In other words,
the result of the interrupt program have been consequently nullified.
Solution
The INT instruction can be used to enable and disable interrupts before and after
the add operation as shown below.
Main program
Interrupts disabled.
Interrupts enabled.
INT (89)
100
000
000
ADD (30)
DM0000
#0001
DM0000
INT (89)
200
000
000
Manipulating One Word