
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Multiply Two 16-Bit Binary Numbers in 8085 Microprocessor
Here we will see one program for Intel 8085 Microprocessor. This program will calculate the multiplication of two 16-bit numbers.
Problem Statement −
Write an 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 – 8001H and 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 |
HEX Codes |
Labels |
Mnemonics |
Comments |
---|---|---|---|---|
F000 |
31, 00, 20 |
|
LXI SP,2000H |
Initialize Stack 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 second 16-bit number |
F00A |
E5 |
|
PUSH H |
Push HL pair into stack |
F00B |
C1 |
|
POP B |
Load BC with HL pair content from stack |
F00C |
21, 00, 00 |
|
LXI H,0000H |
Clear HL pair |
F00F |
22, 52, 80 |
|
SHLD 8052H |
Store 0000H as 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 into Stack |
F017 |
2A, 52, 80 |
|
LHLD 8052 |
Load HL pair from LS 2-bytes of the result |
F01A |
23 |
|
INX H |
Increase HL pair |
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 BC register 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 |
… |
… |
Advertisements