Divide-by-zero, Divide overflow, Divide-by-zero divide overflow – Zilog Z16F2810 User Manual
Page 67

UM018809-0611
System Exceptions
ZNEO
®
CPU Core
User Manual
51
Observe the following steps to set up Stack Overflow Protection.
1. Initialize the Stack Pointer (SP) to its starting location (the highest RAM address +1).
2. Initialize SPOV to the lowest address to which it is safe for the stack to extend, minus
at least 12 bytes to allow room for interrupt completion.
An SPOV exception does not block writes to the stack. When initializing the SPOV regis-
ter, you must provide for at least 12 additional bytes of stack data that might be written
below the programmed address. This occurs if an interrupt generates a Stack Overflow on
the first byte it pushes. In this case the interrupt pushes 5 additional bytes and the excep-
tion itself must push six more before the exception handler can start.
The 11-byte allowance described here is not sufficient if user code manipulates the Stack
Pointer (register R15), either directly or by using the LINK instruction. The allowance
must be increased to accommodate the largest expected decrement of SP.
Divide-by-Zero
If the divisor is zero during execution of a divide instruction (UDIV or SDIV), the ZNEO
CPU generates a Divide-by-Zero system exception. After a Divide-by-Zero has occurred,
the
DIV0
bit in the System Exception register in I/O memory (SYSEXCP) is set to 1. After
the first Divide-by-Zero system exception has executed, no additional Divide-by-Zero
system exceptions are generated until the
DIV0
bit is cleared. Writing 1 to
DIV0
clears the
bit to 0.
For more information about the System Exception register (SYSEXCP), refer to the ZNEO
product specification that is specific to your device .
Divide Overflow
If execution of a divide instruction (UDIV64) results in an overflow, the ZNEO CPU gen-
erates a Divide Overflow system exception. After a Divide Overflow has occurred, the
DIVOVF
bit in the System Exception register in I/O memory (SYSEXCP) is set to 1. After
the first Divide Overflow system exception has executed, no additional Divide Overflow
system exceptions are generated until the
DIVOVF
bit is cleared. Writing 1 to
DIVOVF
clears the bit to 0.
Caution:
Note: