Q) Let an−1an−2...a0 and bn−1bn−2...b0 denote the 2’s complement representation of two integers A and B respectively. Addition of A and B yields a sum S=sn−1sn−2...s0.The outgoing carry generated at the most significant bit position, if any, is ignored. Show that an overflow (incorrect addition result) will occur only if the following Boolean condition holds:
(~sn−1)⊕(an−1sn−1)=bn−1(sn−1⊕an−1)
where ⊕ denotes the Boolean XOR operation and ~ denotes the boolean NOT operation. You may use the Boolean identity: X+Y=X⊕Y⊕(XY) to prove your result.
My Attempt :- When an−1bn−1(~sn−1) + (~an−1)∗(~bn−1)∗sn−1 is 1 then overflow OCCURS otherwise no overflow. Means when 2 positive numbers are added and answer is negative and when 2 negative numbers are added and answer is positive then overflow occurs otherwise it does not occur.
Here,
(~sn−1)⊕(an−1sn−1)=bn−1(sn−1⊕an−1)
(sn−1)(an−1sn−1) + (~sn−1)(~(an−1sn−1))= bn−1(sn−1(~an−1)+ an−1(~sn−1))
After solving further, I am getting finally :-
sn−1an−1 + (~sn−1) = bn−1sn−1(~an−1) + bn−1an−1(~sn−1)
I don't know how to solve further to get the desired result and I also don't know whther I am going in right direction or not. Please help.