
CHAPTER 5 INTERRUPT FUNCTIONS
60
5.2 Software Interrupts
Software interrupts take precedence over hardware interrupts except a BRK flag (single-step) interrupts.
They can be divided as follows.
(1)
Interrupt by instruction result
Divide error by DIV instruction or DIVU instruction
Boundary over detection by CHKIND instruction
When the processing result of an instruction is invalid, an interrupt is automatically generated to allow
exception handling.
(2)
Interrupt by conditional break (execution of BRKV instruction)
In execution of a BRKV instruction, if the V flag is set (1), an interrupt is generated. It is used for processing
an overflow of the operation result.
(3)
Interrupt by unconditional break instruction
1-byte break instruction (BRK 3)
2-byte break instruction (BRK imm8 (
≠
3))
This interrupt is used when branching to a subroutine by a system call or inter-segment call without being
aware of the branch destination.
(4)
BRK flag (single-step) interrupt
This is a useful function for program debugging, etc.
This interrupt is controlled by the BRK flag of PSW. However, it is manipulated with the PSW saved to the
stack, not by an instruction which directly sets/clears the BRK flag and set/cleared processing is indirectly
performed by restoring it to the PSW.
When the BRK flag is set (1), after the next one instruction is executed, the interrupt routine (monitor
program, etc.) specified by vector 1 is started and the BRK flag is also cleared (0) together with the IE flag
at that time.
Therefore, once the vector 1 interrupt is started, interrupt routine instructions are not executed one by one
but continuously in the same way as for other interrupts. Here, the internal registers, flag state, memory
content, etc., can be checked and dumped.
In this interrupt routine, the number of single-steps is checked and if it is possible to terminate the single-
step operation, the BRK flag in the stack is cleared (0) by a memory manipulation instruction and returned.
This allows instructions to be executed continuously after returning to the main routine.
When returning without manipulating the BRK flag, BRK = 1 saved in the stack is restored to the PSW and
after execution of one instruction in the main routine a vector 1 interrupt is generated again.