Integer overflow: Difference between revisions
Content added Content deleted
Puppydrum64 (talk | contribs) |
Puppydrum64 (talk | contribs) |
||
Line 2,588: | Line 2,588: | ||
-2147483648 |
-2147483648 |
||
</pre> |
</pre> |
||
=={{header|Z80 Assembly}}== |
|||
===Zilog Z80=== |
|||
The <code>P</code> flag represents overflow after an arithmetic operation, and bit parity after a bitwise or logical operation. Arithmetic operations will result in overflow if the 7F-80 boundary is crossed. One quirk of the Z80 instruction set is that program counter relative jumps cannot be done based on overflow; only calls, returns, and jumps to fixed memory locations. |
|||
<lang z80> |
|||
ld a,&7F |
|||
add 1 |
|||
jp pe,ErrorHandler ;pe = parity even, but in this case it represents overflow set</lang> |
|||
===Game Boy=== |
|||
The Game Boy is missing all control flow commands pertaining to the overflow flag. However, overflow can still be detected in theory, but it's a difficult process that requires the exclusive or of the carry flag and whether a subtraction changed the sign of the accumulator or not. Since the Game Boy's CPU cannot natively detect overflow, the CPU <b> will continue with a wrong result.</b> |
|||
=={{header|zkl}}== |
=={{header|zkl}}== |