Algorithms for addition and subtraction with signed magnitude data
Answers
Answered by
3
The flowchart is shown in Figure. The two signs A and B are compared by an exclusive-OR gate.

Figure: Flowchart for add and subtract operations.
If the output of the gate is 0 the signs are identical; If it is 1, the signs are different.
For an add operation, identical signs dictate that the magnitudes be added. For a subtract operation, different signs dictate that the magnitudes be added.
The magnitudes are added with a microoperation EA ← A + B, where EA is a register that combines E and A. The carry in E after the addition constitutes an overflow if it is equal to 1. The value of E is transferred into the add-overflow flip-flop AVF.
The two magnitudes are subtracted if the signs are different for an add operation or identical for a subtract operation. The magnitudes are subtracted by adding A to the 2’s complemented B. No overflow can occur if the numbers are subtracted soAVF
is cleared to 0.
1 in E indicates that A >= B and the number in A is the correct result. If this numbs is zero, the sign A must be made positive to avoid a negative zero.
0 in E indicates that A<B. For this case it is necessary to take the 2’s complement of the value in A. The operation can be done with one microoperation A← A’ +1.
However, we assume that the A register has circuits for microoperations complement and increment, so the 2’s complement is obtained from these two microoperations.

Figure: Flowchart for add and subtract operations.
If the output of the gate is 0 the signs are identical; If it is 1, the signs are different.
For an add operation, identical signs dictate that the magnitudes be added. For a subtract operation, different signs dictate that the magnitudes be added.
The magnitudes are added with a microoperation EA ← A + B, where EA is a register that combines E and A. The carry in E after the addition constitutes an overflow if it is equal to 1. The value of E is transferred into the add-overflow flip-flop AVF.
The two magnitudes are subtracted if the signs are different for an add operation or identical for a subtract operation. The magnitudes are subtracted by adding A to the 2’s complemented B. No overflow can occur if the numbers are subtracted soAVF
is cleared to 0.
1 in E indicates that A >= B and the number in A is the correct result. If this numbs is zero, the sign A must be made positive to avoid a negative zero.
0 in E indicates that A<B. For this case it is necessary to take the 2’s complement of the value in A. The operation can be done with one microoperation A← A’ +1.
However, we assume that the A register has circuits for microoperations complement and increment, so the 2’s complement is obtained from these two microoperations.
Similar questions