SIGNED COMPLEMENT ARITHMETIC –
In signed complement no. representation system, there are two cases –
1. Numbers to be added have opposite sign.
2. Numbers have same sign.
$IWHUDGGLWLRQRIWKHWZRQXPEHUVYDULRXVIODJVZLOOEHVHWWKHQZhat will the carry flag
indicate in each case and how are we to LQWHUSUHW the correct result from the status of
carry flag ??
CASE 1 –
Here if the carry flag is set after the addition (any operation addition or
subtraction is done in form of addition in signed complement representation,
this is the advantage of this representation system), then the result is positive
and can be directly interpreted from the result of addition.
But if the carry flag is reset, them the result is negative and is present in the
result of addition in complemented form, the correct result should then be
obtained by finding complement of the result and putting a ‘-‘ sign in front of
it.
Reason – The carry flag will be set only when the no. to be subtracted is smaller
in magnitude, because if magnitude is small then in complemented form the
magnitude will be large, which will be enough to produce a carry when added
with the other +ve number.
Eg:- M= +4 ----> +4 +4 ----> +4
N = -2 ----> +8 -7 ----> +3
------ ------- ----- -----
+2 ----> 12 -3 7
Had N been equal to -7 then in 10’s complement form it would have been simply
+3, and 4 + 3 = 7 ,i.e., no carry generated.
Thus a carry will not be generated if magnitude of –ve number is greater than +ve
number.
CASE 2 –
If the Carry Flag is SET then there are two possibilities –
1. The Overflow Flag is Set.
2. The Overflow Flag is Reset.
Case (i) – The overflow flag is set, then it means that the numbers were +ve
and result of addition could not be accommodated in given no. of bits for
number representation.
Eg:- +44 (10’s complement form) ----> +44
+62 (10’s complement form) ----> +62
----- ------
+106 (3 digit result, overflow) 1 06
(Notice that there is no in carry in MSB and Carry flag is set)
Case (ii) – The overflow flag is reset, then it means that the numbers were –ve
and the result is –ve and is in complemented form.
Eg:- - 24 (10’s complement form) ----> +76
- 52 (10’s complement form) ----> +48
----- ------
- 76 (2 digit result, No overflow) 1 24
24 is nothing but 10’s complement form of - 76.
(Notice that there is an in carry in MSB and Carry flag is set)
If the Carry Flag is RESET then two possibilities –
1. The Overflow Flag is Set.
2. The Overflow Flag is Reset.
Case (i) – The overflow flag is set, then it means that the numbers were –ve
and the result could not be accommodated in the given no. of bits for
representing numbers.
Eg:- - 54 (10’s complement form) ----> +46
- 72 (10’s complement form) ----> +28
----- ------
- 126 (3 digit result, overflow) 0 74
(Notice that there is an in carry in MSB and Carry flag is reset)
Case (ii) – The overflow flag is reset, it means that the numbers were +ve
and the result is +ve and the result of addition that can be directly taken.
Eg:- +34 (10’s complement form) ----> +34
+52 (10’s complement form) ----> +52
----- ------
+86 (2 digit result, no overflow) 0 86
14 is nothing but 10’s complement form of - 86
(Notice that there is no in carry in MSB and Carry flag is reset)