198
6-4. Hints for Programming High-level Instructions
4. Overflow and Underflow
1) Overflow and Underflow
• When performing some instructions, the operation result may exceed the maximum overflow or go below the
minimum underflow in the range of 16-bit or 32-bit data.
When an overflow or underflow occurs, the carry flag (R9009) turns ON.
2) Overflow and Underflow in Binary Operations (16-bit or 32-bit)
■ 16-bit Binary Operation
■ 32-bit Binary Operation
Example:
• Overflow
When DT0 = K32767 and DT1 = K1,
K-32768 is stored in DT100 and R9009 turns ON.
• Underflow
When DT0 = K-32768 and DT1 = K-1,
K32767 is stored in DT100 and R9009 turns ON.
• Overflow:
The result becomes a negative minimum
value (K-2147483648/H80000000) if K1
is added to the positive maximum value
(K2147483647/H7FFFFFFF).
• Underflow:
The result becomes a positive maximum
value (K2147483647/H7FFFFFFF) if K1
is subtracted from the negative minimum
value (K-2147483648/H80000000).
• Overflow:
The result becomes a negative minimum
value (K-32768/H8000) if K1 is added to
the positive maximum value
(K32767/H7FFF).
• Underflow:
The result becomes a positive maximum
value (K32767/H7FFF) if K1 is
subtracted from the negative minimum
value (K-32768/H8000).