70 likes | 241 Views
Addition and Subtraction with Signed-Magnitude Data (Mano, Section 10-2). Basics Seminar, CSc 8215 High Performance Computing (2005 Fall) Mary R. Hudachek-Buswell. Sign-magnitude number.
E N D
Addition and Subtraction with Signed-Magnitude Data (Mano, Section 10-2) Basics Seminar, CSc 8215 High Performance Computing (2005 Fall) Mary R. Hudachek-Buswell
Sign-magnitude number A sign-magnitude number Z can be represented as (As, A) where As is the sign of Z and A is the magnitude of Z. The leftmost position, As, is the sign bit. The sign bit is either positive = 0 or negative = 1
Example of adding two magnitudes when the result is the sign of both operands: +3 0 011 + +2 0 010 +5 0 101 Examples -3 1 011 + +2 0 010 -( +3 011 - +2) 010 - 1 1 001 Example of adding two magnitudes when the result is the sign of the larger magnitude:
Start Subtraction Start Addition Bs = Bs’ As = Bs A > B Ar = A + B Ars = As A = B Ar = A – B Ars = As Ar = 0 Ars = 0 Done Flowchart of Addition and Subtraction with Signed-Magnitude Data Ar = B – A Ars = Bs
The signs use an exclusive OR gate where if the output is 0, then the signs are the same. Hence, add the magnitudes of the same signed numbers. If the sum is an overflow, then a carry is stored in E where E = 1 and transferred to the flip-flop AVF, add-overflow. Otherwise, the signs are opposite and subtraction is initiated and stored in A. No overflow can occur with subtraction so the AVF is cleared. If E = 1, then A > B. However, if A = 0, then A = B and the sign is made positive. If E = 0, then A < B and sign for A is complemented. Summary of Addition and Subtraction with Signed-Magnitude Data
Addition and Subtraction with Signed-Magnitude Data Hardware Design B register Bs Mode Control Complementer AVF M Parallel Adder E Input Carry Output Carry S A register As Load Sum