Presentation is loading. Please wait.

Presentation is loading. Please wait.

Addition and Subtraction with Signed- Magnitude Data (Mano, Section 10-2) Basics Seminar, CSc 8215 High Performance Computing (2005 Fall) Mary R. Hudachek-Buswell.

Similar presentations


Presentation on theme: "Addition and Subtraction with Signed- Magnitude Data (Mano, Section 10-2) Basics Seminar, CSc 8215 High Performance Computing (2005 Fall) Mary R. Hudachek-Buswell."— Presentation transcript:

1 Addition and Subtraction with Signed- Magnitude Data (Mano, Section 10-2) Basics Seminar, CSc 8215 High Performance Computing (2005 Fall) Mary R. Hudachek-Buswell Basics Seminar, CSc 8215 High Performance Computing (2005 Fall) Mary R. Hudachek-Buswell

2 Sign-magnitude number A sign-magnitude number Z can be represented as (A s, A) where A s is the sign of Z and A is the magnitude of Z. The leftmost position, A s, is the sign bit. The sign bit is either positive = 0 or negative = 1 Number Signed- Magnitude +30 11 +20 10 +10 01 +00 00 -01 00 1 01 -21 10 -31 11

3 Eight Conditions for Signed- Magnitude Addition/Subtraction Operation ADD Magnit udes SUBTRACT Magnitudes A > BA < BA = B (+A) + (+B)+ (A + B) (+A) + (-B)+ (A – B )- (B – A )+ (A – B ) (-A) + (+B)- (A – B )+ (B – A )+ (A – B ) (-A) + (-B)- ( A + B) (+A) - (+B)+ (A – B )- (B – A )+ (A – B ) (+A) - (-B)+ (A + B) (-A) - (+B)- ( A + B) (-A) - (-B)- (A – B )+ (B – A )+ (A – B )

4 Examples Example of adding two magnitudes when the result is the sign of both operands: +3 0 011 + +2 0 010 +5 0 101 Example of adding two magnitudes when the result is the sign of the larger magnitude: -3 1 011 + +2 0 010 -( +3 011 - +2) 010 - 1 1 001 -3 1 011 + +2 0 010 -( +3 011 - +2) 010 - 1 1 001

5 Flowchart of Addition and Subtraction with Signed-Magnitude Data A r = B – A A rs = B s Start Subtraction Start Addition B s = B s ’ A s = B s A r = A + B A rs = A s A > B A r = A – B A rs = A s A = B A r = 0 A rs = 0 Done

6 Summary of Addition and Subtraction with Signed-Magnitude Data 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. 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.

7 Addition and Subtraction with Signed- Magnitude Data Hardware Design A register AVF E BsBs A s B register Complementer Parallel Adder S Load Sum M Mode Control Input Carry Output Carry


Download ppt "Addition and Subtraction with Signed- Magnitude Data (Mano, Section 10-2) Basics Seminar, CSc 8215 High Performance Computing (2005 Fall) Mary R. Hudachek-Buswell."

Similar presentations


Ads by Google