Auxiliary carry is the carry from 1st nibble to 2nd nibble.
Ex:
0000 0000 0000 1000
+0000 0000 0000 1100
=0000 0000 000
1 0100
The underlined bit is auxiliary carry.
CY is carry from MSB, In 8051 it is carry from 15th bit.
Ex:
1000 0000 0000 0000 (8000)
+ 1100 0000 0000 0000 (C000)
= 0100 0000 0000 0000 (1400) With carry 1
Note that the addition above i have done is unsigned addition.
Overflow occurs only while doing signed addition. When Added result is not in the range then we say overflow has occured. In signed addition MSB(most significant bit) is taken as sign bit.
In case of 16bit signed addition (i.e in case of 8051) The range is +32768 to -32767, i.e +7FFF to -7FFE. 15th bit is sign bit.
I will give some examples,
1000 0000 0000 0000 (-0000) (To get it in hex take 2's compliment since
+ 1111 0000 0000 0000 (-1000) ( 15th bit is '1' and hence number is
0111 0000 0000 0000 (+7000) ( negative
Here overflow occured. Both additive elements are negative, but the result is positive since the 15th bit is '0'. When We add (-0000) and (-1000) Ans should be (-1000) But here it is +7000. Hence it is Overflow
0111 0000 0000 0000 (+7000)
+0100 0000 0000 0000 (+4000)
=1011 0000 0000 0000 (-5000)
here also over flow occured, both additives are positive but the result is negative,
Note 1: If 15th bit is '0' then number is positive and you should not take 2's compliment.
Note 2: In both example observe that sign change occured from Additive elements to Result. In 1st example both numbers were negative but Ans is positive. In 2nd example both numbers were positive but Ans is negative.
And hence one can conclude that When there is such a sign change overflow is occured.
Note 3: When the additive elements are of opposite sign, overflow never can occur. Its obvious and my promise.