8085 Program to Multiply Two 16-Bit Binary Numbers



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

Address Data
.
.
.
.
.
.
8000 11
8001 11
8002 11
8003 11
.
.
.
.
.
.

second input 

Address Data
.
.
.
.
.
.
8000 24
8001 1C
8002 52
8003 07
.
.
.
.
.
.


Flow Diagram

Program

Address HEXCodes Labels Mnemonics Comments
F000 31, 00, 20
LXI SP,2000H    InitializeStack pointer
F003 2A, 00, 80
LHLD 8000H   Load 16-bit data from 8000H - 8001H
F006 EB
XCHG     Exchange the data from HL and DE
F007 2A, 02, 80
LHLD 8002H   Load second16-bit number
F00A E5
PUSH H   Push HL pair into stack
F00B C1
POP B    Load BC withHL pair content from stack
F00C 21, 00, 00
LXI H,0000H Clear HL pair
F00F 22, 52, 80
SHLD 8052H    Store 0000Has LS 2-bytes of the result
F012 19 LOOP DAD D    Add first number to HL pair
F013 D2, 1F, F0
JNC NINC     if CY = 0,jump to NINC
F016 E5
PUSH H   Push HL intoStack
F017 2A, 52, 80
LHLD 8052    Load HL pair from LS 2-bytes of the result
F01A 23
INX H    Increase HLpair
F01B 22, 52, 80
SHLD 8052H    Store HL pair as LS 2-bytes of the result  
F01E E1
POP H    Pop stack content to HL pair
F01F 0B NINC DCX B    Decrease BCregister pair
F020 78
MOV A,B Load B to A
F021 B1
ORA C    OR C with A
F022 C2, 12, F0
JNZ LOOP     When Z = 0,jump to LOOP
F025 22, 50, 80
SHLD 8050H   Store HL pair to 8050H
F028 76
HLT Terminate the program


Output

first output

Address Data
.
.
.
.
.
.
8050 21
8051 43
8052 23
8053 01
.
.
.
.
.
.

second output 

Address Data
.
.
.
.
.
.
8050 88
8051 FF
8052 CD
8053 00
.
.
.
.
.
.
Updated on: 2019-07-30T22:30:24+05:30

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements