Difference between revisions of "Overflow Flag"

From Intellivision Wiki
Jump to: navigation, search
(a little more info to make it clearer)
m (Protected "Overflow Flag" ([edit=autoconfirmed] (indefinite) [move=autoconfirmed] (indefinite)))
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
The Overflow Flag indicates that the previous operation resulted in a signed number whose sign was inconsistent with the signs of the operands that produced it.  For instance, the Overflow Flag gets set when adding two positive numbers produces a negative result, or adding two negative numbers produces a positive result.
+
The Overflow Flag indicates that the previous operation resulted in a signed number whose sign was inconsistent with the signs of the operands that produced it—signed integer overflow.  For instance, the Overflow Flag gets set when adding two positive numbers produces a negative result, or adding two negative numbers produces a positive result.
  
 
The truth table below indicates when the CPU sets or clears the Overflow Flag:
 
The truth table below indicates when the CPU sets or clears the Overflow Flag:

Latest revision as of 09:01, 4 December 2010

The Overflow Flag indicates that the previous operation resulted in a signed number whose sign was inconsistent with the signs of the operands that produced it—signed integer overflow. For instance, the Overflow Flag gets set when adding two positive numbers produces a negative result, or adding two negative numbers produces a positive result.

The truth table below indicates when the CPU sets or clears the Overflow Flag:

Addition
Sign of first operandSign of second operandSign of resultResulting value of Overflow FlagNotes
0000
0011Adding two positive numbers produced a negative result
0100
0110
1000
1010
1101Adding two negative numbers produced a positive result
1110
Subtraction
Sign of value
being subtracted
(subtrahend)
Sign of value
being subtracted from
(minuend)
Sign of resultResulting value of Overflow Flag
0000
0010
0101Subtracting a positive number from a negative number gave a positive result.
0110
1000
1011Subtracting a negative number from a positive number gave a negative result.
1100
1110