Assignment III
Assignment III
Soln: Here the multiplicand is stored in location E050H and the multiplier is stored
in E051H .The result will be stored in E070H(LSB Byte) and E071H(MSB Byte).
First we are checking if multiplicand or multipler is zero.If any one or both are zero
then there is no need to perform multiplication and 00H is stored in E070H and
E071H.Otherwise the multiplication is done by Add and Shift method and result is
stored in the same location.Here we check the multiplier bit and if it is 1 then
multiplicand is added with the output location(initially zero) and shifted left by one
bit and if multiplier bit is 0 addition is skipped and partial product is shifted left by
1bit.This continues until all multiplier bit is checked.
Address Hex Code Opcode Operand Comments
8000H 31 F0 FF LXI SP,FFF0H Initialize Stack Pointer
8003H 2A 50 E0 LHLD E050H Place contents of E050H in L
register and contents of E051H in
H register
8006H EB XCHG Multipler in D and multiplicand
in E
8007H 21 00 00 LXI H,0000H Clear HL pair
800AH 7A MOV A,D
800BH FE 00 CPI 00H }Check if multipler is zero and
800DH CA 19 00 JZ 8019H terminate process if it is zero
8010H 7B MOV A,E
8011H
8013H
FE 00
CA 19 00
CPI
JZ
00H
8019H
}Check if multiplicand is zero
and terminate process if it is zero
8016H CD 1D 00 CALL 801DH Call subroutine for
multiplication
8019H 22 70 E0 SHLD E070H Store the result in E070H(LSB
Byte)and E071H (MSB Byte)
801CH CF RST1 Restart
801DH 7A MOV A,D Take multiplier in Accumulator
801EH 16 00 MVI D,00H Clear D to use DAD instruction
8020H 06 08 MVI B,08H Set up counter to count no of
bits to be rotated
8022H 1F RAR Check if multiplier bit is 1
8023H D2 27 00 JNC 8027H If not skip adding multiplicand
RESULT:
INPUT: OUTPUT:
MEMORY CONTENT
MEMORY CONTENT
LOCATION
LOCATION
E070H 0CH
E050H 04H
E051H 03H E071H 00H
2. Write an Assembly Language Program for 8085 Microprocessor to multiply
two 8 bit no using Repeated Addition Method. The program must have a check
for zero input condition.
Soln: :Here the multiplicand is stored in location 2000H and the multiplier is stored
in 2001H .The result will be stored in 2500H(LSB Byte) and 2501H(MSB Byte). First
we are checking if multiplicand or multipler is zero. If any one or both are zero then
there is no need to perform multiplication and 00H is stored in 2500H and
2501H.Otherwise the multiplication is done by repeated addition method and result is
stored in the same location. For this we decrement the multiplier by one each time and
go on adding multiplicand with the partial product(which is initialised with zero) until
multiplier becomes zero.
Address Hex Code Opcode Operand Comments
8000H 21 00 20 LXI H,2000H Set up memory pointer
8003H 7E MOV A,M
8004H C6 00 ADI 00H }Check if multiplicand is zero and
8006H CA 1D 80 JZ 801DH terminate if if it is zero
8009H 4F MOV C,A Copy multiplicand in register C
800AH 23 INX H Increament memory pointer
800BH 7E MOV A,M
800CH C6 00 ADI 00H }Check if multiplier is zero and
800EH CA 1D 00 JZ 801DH terminate if if it is zero
8011H 06 00 MVI B,00H Clear register B
8013H 60 MOV H,B Clear register H
8014H 69 MOV L,C Multiplicand in register C
8015H 3D DCR A Decrement Multiplier
8016H CA 21 80 JZ 8021H Goto 8021H if multipler becomes
zero
8019H 09 DAD B Add multiplicand with itself and
store in HL pair
801AH C3 15 80 JMP 8015H Goto 8015H to repeat the task
801DH 26 00 MVI H,00H
801FH 2E 00 MVI L,00H }Store all zero in HL pair if
multiplicand and multiplier is zero
8021H 44 MOV B,H Copy contentf of H in register B
8022H 4D MOV C,L Copy contentf of L in register C
8023H 21 00 25 LXI H,2500H Set up memory pointer for output
location
8026H 71 MOV M,C Store low oreder byte in 2500H
8027H 23 INX H Increament memory pointer
8028H 70 MOV M,B Store high oreder byte in 2501H
8029H 76 HLT Wait
RESULT:
INPUT: OUTPUT:
RESULT:
INPUT: OUTPUT: