
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
Divide Two 16-Bit Numbers in 8085
Here we will see how to divide two 16 bit numbers using 8085.
Problem Statement
Write 8085 Assembly language program to divide two 16-bit numbers.
Discussion
8085 has no division operation. To perform division, we have to use repetitive subtraction. To perform 16-bit division, we have to do the same but for the register pairs. As the register pairs are used to hold 16-bit data.
The Divisor is stored at location FC00 and FC01, the dividend is stored at FC02 and FC03. After division, the quotient will be stored at FC04 and FC05, and the remainder will be stored at FC06 and FC07.
Input
Address |
Data |
---|---|
FC00 |
8A |
FC01 |
5C |
FC02 |
5A |
FC03 |
1D |
Flow Diagram
Program
Address |
HEX Codes |
Labels |
Mnemonics |
Comments |
---|---|---|---|---|
F000 |
01, 00, 00 |
|
LXI B,0000H |
Clear BC register pair |
F003 |
2A, 02, FC |
|
LHLD FC02H |
Take the Divisor into HL first |
F006 |
EB |
|
XCHG |
Exchange DE and HL |
F007 |
2A, 00, FC |
|
LHLD FC00H |
Take the dividend |
F00A |
7D |
LOOP |
MOV A,L |
Load L into A |
F00B |
93 |
|
SUB E |
Subtract E from A |
F00C |
6F |
|
MOV L,A |
Store A into L |
F00D |
7C |
|
MOV A,H |
Load H into A |
F00E |
9A |
|
SBB D |
Subtract B from A with Borrow |
F00F |
67 |
|
MOV H,A |
Store A into H again |
F010 |
DA, 17, F0 |
|
JC SKIP |
If CY is 1, Skip |
F013 |
03 |
|
INX B |
Increase B by 1 |
F014 |
C3, 0A, F0 |
|
JMP LOOP |
Jump to Loop |
F017 |
19 |
SKIP |
DAD D |
Add HL and DE |
F018 |
22, 06, F0 |
|
SHLD FC06H |
Store remainder into FC06 and FC07 |
F01B |
69 |
|
MOV L,C |
Load C into L |
F01C |
60 |
|
MOV H,B |
Load B into H |
F01D |
22, 04, FC |
|
SHLD FC04H |
Store quotient into FC04 and FC05 |
F020 |
76 |
|
HLT |
Terminate the program |
Output
Address |
Data |
---|---|
FC04 |
03 |
FC05 |
00 |
FC06 |
7C |
FC07 |
04 |
Advertisements