M16C Family does not have a function to detect the division by "0".
As stated in the software manual of each MCU Series, when the divider value is "0", the overflow flag (O flag) in the FLG Register becomes "1" (the division result is undetermined). The division by "0" is detectable by checking the divider using an overflow interrupt. The jump address of an overflow interrupt is assigned in the fixed vecter table and an interrupt can be generated by executing the INTO instruction. The INTO instruction is a nonmaskable interrupt.
Ex) DIV.B INTO
After the DIV.B instruction is executed, if the O flag is "1", the INTO instruction generates an overflow interrupt. If the O flag is "0", an interrupt is not generated and the next instruction is executed.
|M16C/6NK, M16C/6NL, M16C/6NM, M16C/6NN|