8085 Program to multiply two 16-bit binary numbers

MicrocontrollerMicroprocessor8085

Now let us see a program of Intel 8085 Microprocessor. This program will calculate the multiplication of two 16-bit numbers.

Problem Statement

Write 8085 Assembly language program to multiply two 16-bit numbers stored at 8000H -8001H and 8002H - 8003H.

Discussion

This program takes the 16 bit data from memory location 8000H – 8001Hand 8002H – 8003H. The 32 bit results are stored at location 8050H– 8053H.

Here we have tested with two 16 bit numbers. The results are as follows

      1111H × 1111H = 01234321H 

      1C24H × 0752H = 00CDFF88H

Input

first input

AddressData
.
.
.
.
.
.
800011
800111
800211
800311
.
.
.
.
.
.

second input 

AddressData
.
.
.
.
.
.
800024
80011C
800252
800307
.
.
.
.
.
.


Flow Diagram

Program

AddressHEXCodesLabelsMnemonicsComments
F00031, 00, 20
LXI SP,2000H   InitializeStack pointer
F0032A, 00, 80
LHLD 8000H  Load 16-bit data from 8000H - 8001H
F006EB
XCHG    Exchange the data from HL and DE
F0072A, 02, 80
LHLD 8002H  Load second16-bit number
F00AE5
PUSH H  Push HL pair into stack
F00BC1
POP B   Load BC withHL pair content from stack
F00C21, 00, 00
LXI H,0000HClear HL pair
F00F22, 52, 80
SHLD 8052H   Store 0000Has LS 2-bytes of the result
F01219LOOPDAD D   Add first number to HL pair
F013D2, 1F, F0
JNC NINC    if CY = 0,jump to NINC
F016E5
PUSH H  Push HL intoStack
F0172A, 52, 80
LHLD 8052   Load HL pair from LS 2-bytes of the result
F01A23
INX H   Increase HLpair
F01B22, 52, 80
SHLD 8052H   Store HL pair as LS 2-bytes of the result  
F01EE1
POP H   Pop stack content to HL pair
F01F0BNINCDCX B   Decrease BCregister pair
F02078
MOV A,BLoad B to A
F021B1
ORA C   OR C with A
F022C2, 12, F0
JNZ LOOP    When Z = 0,jump to LOOP
F02522, 50, 80
SHLD 8050H  Store HL pair to 8050H
F02876
HLTTerminate the program


Output

first output

AddressData
.
.
.
.
.
.
805021
805143
805223
805301
.
.
.
.
.
.

second output 

AddressData
.
.
.
.
.
.
805088
8051FF
8052CD
805300
.
.
.
.
.
.
raja
Published on 21-Jan-2019 15:40:08
Advertisements