Write a program to Multiply Two 8 Bit Numbers using  Add and Shift Method in Assembly language .Program should take first and second numbers as input to the program . Now it should implement certain logic to multiply 8 bit Numbers using  Add and Shift Method .
Consider that one byte is present in the AL register and another byte is present in the BL register.
We have to multiply the byte in AL with the byte in BL.
We will multiply the numbers using add and shift method. In this method, you add number with itself and rotate the other number each time and shift it by one bit to left alongwith carry. If carry is present add the two numbers.
Initialize the count to 4 as we are scanning for 4 digits. Decrement counter each time the bits are added. The result is stored in AX. Display the result.
                        For example :   AL = 11 H,  BL = 10 H, Count = 4
Step I       :
AX =
11
+
11
22 H
                               Rotate BL by one bit to left along with carry.
BL = 10 H
0
¬
0
0
0
1
0
0
0
0
 ­
CY
BL =
0
0
0
1
0
0
0
0
0
CY
2
0
Step II     :    Now decrement counter count = 3.
                               Check for carry, carry is not there so add number with itself.
AX =
22
+
22
44 H
                               Rotate BL to left,
BL =
0
¬
0
1
0
0
0
0
0
0
CY
4
0
                               Carry is not there.
                               Decrement count, count=2
Step III   :    Add number with itself
AX =
44
+
44
88 H
                      Rotate BL to left,
BL =
0
1
0
0
0
0
0
0
0
CY
8
0
                               Carry is not there.
Step IV :      Decrement counter count = 1.
                               Add number with itself as carry is not there.
AX =
88
+
88
110 H
                               Rotate BL to left,
BL =
1
0
0
0
0
0
0
0
0
CY
0
0
                               Carry is there.
Step V :        Decrement counter = 0.
                               Carry is present.
                               \ add AX, BX
\
0110
i.e.
11 H
+
0000
´
10 H
0110 H
0110 H
Algorithm to Multiply Two 8 Bit Numbers using  Add and Shift Method:  


 

Step I          :    Initialize the data segment.
Step II        :    Get the first number.
Step III      :    Get the second number.
Step IV       :    Initialize count = 04.
Step V        :    number 1 = number 1 ´ 2.
Step VI       :    Shift multiplier to left along with carry.
Step VII     :    Check for carry, if present go to step VIII else go to step IX.
Step VIII   :    number 1 = number1 + shifted number 2.
Step IX      :    Decrement counter.
Step X        :    If not zero, go to step V.
Step XI      :    Display the result.
Step XII     :    Stop.

 

 

Program to Multiply Two 8 Bit Numbers using  Add and Shift Method:

 

How to Run this Program : 

For Running this program you should have installed Tasm on you computer . If you have not installed Tasm  yet please install from Here .

C:\programs>tasm shaddmul.asm
Turbo Assembler  Version 3.0  Copyright (c) 1988, 1991 Borland International
Assembling file:   shaddmul.asm
Error messages:    None
Warning messages:  None
Passes:            1
Remaining memory:  438k
C:\programs>tlink shaddmul.obj
Turbo Link  Version 3.0 Copyright (c) 1987, 1990 Borland International
Warning: No stack
C:\programs>shaddmul
0110