Coa Notes Unit-3
Coa Notes Unit-3
Coa Notes Unit-3
INFORMATION TECHNOLOGY
DIGITAL NOTES
[Department of Computer Application]
SESSION 2024-25
Addition and Subtraction with Signed Magnitude Data
Addition Algorithm
The addition algorithm specifies that:
• If the signs of P and Q are the same, add both the magnitudes and put the sign
of P to the result, as shown in the table below.
• Compare both the magnitudes and subtract the small number from the greater
number when the signs of P and Q disagree.
• In cases where P > Q, the output signs must be equal to P, or the complement
of P's sign in cases where P < Q.
• Subtract Q from P and change the sign of the output to positive when the two
magnitudes are equal.
Subtraction Algorithm
The subtraction algorithm states that:
• When the signs of P and Q differ, the subtraction method says to add both the
magnitudes and put the sign of P to the result.
• Compare both the magnitudes and subtract the smaller number from the greater
number when the signs of P and Q are the same.
• In cases where P > Q, the output signs must be equal to P, or the complement
of P's sign in cases where P < Q.
• Subtract Q from P and change the sign of the output to positive when the two
magnitudes are equal.
Operations Addition of Magnitudes Subtraction of Magnitudes
Flowchart
1. Registers:
Two Registers B and Q are used to store multiplicand and multiplier
respectively.
Register A is used to store partial product during multiplication.
Sequence Counter register (SC) is used to store number of bits in the
multiplier.
2. Flip Flop:
To store sign bit of registers we require three flip flops (A sign, B sign and
Q sign).
Flip flop E is used to store carry bit generated during partial product
addition.
3. Complement and Parallel adder:
This hardware unit is used in calculating partial product i.e, perform
addition required.
Flowchart of Multiplication:
1. Initially multiplicand is stored in B register and multiplier is stored in Q
register.
2. Sign of registers B (Bs) and Q (Qs) are compared using XOR functionality
(i.e., if both the signs are alike, output of XOR operation is 0 unless 1) and
output stored in As (sign of A register).
Note: Initially 0 is assigned to register A and E flip flop. Sequence counter is
initialized with value n, n is the number of bits in the Multiplier.
3. Now least significant bit of multiplier is checked. If it is 1 add the content of
register A with Multiplicand (register B) and result is assigned in A register
with carry bit in flip flop E. Content of E A Q is shifted to right by one
position, i.e., content of E is shifted to most significant bit (MSB) of A and
least significant bit of A is shifted to most significant bit of Q.
4. If Qn = 0, only shift right operation on content of E A Q is performed in a
similar fashion.
5. Content of Sequence counter is decremented by 1.
6. Check the content of Sequence counter (SC), if it is 0, end the process and
the final product is present in register A and Q, else repeat the process.
Example: Multiply the two numbers 7 and 3 by using the Booth's multiplication
algorithm.
Ans. Here we have two numbers, 7 and 3. First of all, we need to convert 7 and 3 into
binary numbers like 7 = (0111) and 3 = (0011). Now set 7 (in binary 0111) as multiplicand
(M) and 3 (in binary 0011) as a multiplier (Q). And SC (Sequence Count) represents the
number of bits, and here we have 4 bits, so set the SC = 4. Also, it shows the number
of iteration cycles of the booth's algorithms and then cycles run SC = SC - 1 time.
Qn Qn + 1 M = (0111) AC Q Qn + 1 SC
M' + 1 =
(1001) &
Operation
Subtract (M'
1001
+ 1)
1001
Perform
Arithmetic
Right Shift 1100 1001 1 3
operations
(ashr)
Perform
Arithmetic
1 1 Right Shift 1110 0100 1 2
operations
(ashr)
Addition (A
0 1 0111
+ M)
0101 0100
Perform
Arithmetic
0010 1010 0 1
right shift
operation
Perform
Arithmetic
0 0 0001 0101 0 0
right shift
operation
Arithmetic operations
Last Updated: 2023-05-24
The plus sign and the minus sign can appear as prefix operators or as infix operators. All other
arithmetic operators can appear only as infix operators.
Prefix operators can precede and be associated with any of the operands of an infix operation.
For example, in the expression A*-B, the minus sign indicates that the value of A is multiplied
by -1 times the value of B.
More than one prefix operator can precede and be associated with a single variable. More than
one positive prefix operator has no cumulative effect, but two negative prefix operators have
the same effect as a single positive prefix operator.
Decimal arithmetic operations refer to a digital function that does decimal micro-
operations. This function adds or subtracts decimal numbers by forming 9’s or 10’s
complement of the subtrahend. This decimal arithmetic unit first accepts coded
decimal numbers and then generates output in the binary form.
Algorithms that are used for arithmetic operations with decimal data and binary data
are alike. If the micro-operations symbol is interpreted correctly the same flowchart
can be used for both multiplication and division.
The decimal numbers in BCD are stored in groups of four bits in the computer
registers. When performing decimal micro-operations, every 4-bit group represents
a decimal digit and has to be taken as a group
Y′ 9’s complement of Y.
In this table, we can see a bar over the symbol for the register letter. This refers to
the 9’s complement of decimal number that is stored in the register. When 1 is added
to the 9’s complement the 10’s complement is produced.
It may be confusing to use similar symbols for 9’s complement and 1’s complement
in case both types of data are used in the same system.
Therefore, it would be better to implement a different symbol for the 9’s complement.
In case only one type of data is taken into consideration, the symbol would apply to
the type of data used.