Addition and Subtraction Using Signed Magnitude Form
Addition and Subtraction Using Signed Magnitude Form
1 (+A) + (+B) + (A + B)
2 (+A) + (-B) + (A – B ) - (B – A ) + (A – B )
3 (-A) + (+B) - (A – B ) + (B – A ) + (A – B )
4 (-A) + (-B) - ( A + B)
5 (+A) - (+B) + (A – B ) - (B – A ) + (A – B )
6 (+A) - (-B) + (A + B)
7 (-A) - (+B) - ( A + B)
8 (-A) - (-B) - (A – B ) + (B – A ) + (A – B )
Addition and Subtraction with
Signed magnitude data
ALGORITHM:
• When the sign of A and B are identical, add the
two magnitudes and attach the sign of A to the
result.
• When the sign of A and B are different, compare
the magnitudes, subtract smaller number from
the larger.
• Choose the sign of the result to be same as A if
A>B or complement the sign of A if A<B.
• If the two magnitudes are equal, subtract B from
A and Make the sign of the result positive.
Hardware for signed-magnitude
addition and subtraction
Bs B register
Mode Control
AVF Complementer M
Output
E Carry Parallel Adder Input Carry
S
=1 =0
As ≠ As + BS
BS
EA A + B +1 As = BS
AVF 0
=0 =1 EA A+ B
A<B E A>=B
A A A
≠0 =0
AVF E
As 0
A A+1
As As
END
• For Example of Addition
• (+1) + (+2)
(+A) + (+B)
Add Augend in A
operation Added in B
=1 =0
As ≠ BS As + BS
EA A + B +1 As = BS
AVF 0
=0 =1 EA A+ B
A<B E A>=B
A A A
≠0 =0
AVF E
As 0
A A+1
As As
END
• (-1) + (+2)
(-A) + (+B)
Take A=-1, B=+2 and perform the calculation
Add Augend in A
operation Added in B
=1 =0
As ≠ BS As + BS
EA A + B +1 As = BS
AVF 0
=0 =1 EA A+ B
A<B E A>=B
A A A
≠0 =0
AVF E
As 0
A A+1
As As
END
• For Example of Subtraction
• (+1) - (-2)
(+A) - (-B)
Subtract Miuend in A
operation Subtrahend in B
=0 =1
As + BS
As = BS
EA A + B +1
AVF 0
As ≠ BS
=0 =1 EA A+ B
A<B E A>=B
A A A
≠0 =0
AVF E
As 0
A A+1
As As
END
• (+5) – (+2)
(+A) – (+B)
Subtract Miuend in A
operation Subtrahend in B
=0 =1
As + BS
As = BS
EA A + B +1
AVF 0
As ≠ BS
=0 =1 EA A+ B
A<B E A>=B
A A A
≠0 =0
AVF E
As 0
A A+1
As As
END