8085 Program to Divide a 16-bit Number by an 8-bit Number



In this program we will see how to divide a 16-bit number by an 8-bit number

Problem Statement

Write 8085 Assembly language program to divide a 16-bit number by an 8-bit number.

Discussion

In this program we are taking the 16-bit number from 8000H and 8001H. The 8000H is holding the lower order byte and 8001H is holding higher order byte. The8002H is holding the 8-bit numerator. After dividing the number the16-bit quotient is stored at location 8050H and 8051H. The remainderis stored at 8052H.

Input

Address Data
.
.
.
.
.
.
8000 2B
8001 CA
8002 53
.
.
.
.
.
.


Flow Diagram

Program

Address HEX Codes Labels Mnemonics Comments
F000 21, 00, 80
LXI H,8000H Point 8000Haddress
F003 7E
MOV A, M Store the lower order byte
F004 23
INX H    Increase the HL pair to point next loc
F005 46
MOV B, M Store the higher order byte
F006 23
INX H    Increase the HL pair to point next loc
F007 4E
MOV C, M Load the denominator
F008 04
INR B Increase B register
F009 21, 00, 00
LXI H,0000H Store 0000Hinto HL pair
F00C 91 LOOP SUB C    Subtract C from acc
F00D DA, 14, F0
JC SKIP     Jump to SKIPwhen CY = 1
F010 23 INCR INX H    Increase quotient part
F011 C3, 0C, F0
JMP LOOP    Jump to LOOP
F014 05 SKIP DCR B    Decrease B
F015 CA, 1B, F0
JZ STORE     Jump to STOREwhen Z = 1
F018 C3, 10, F0
JMP INCR     Jump to INCR
F01B 81 STORE ADD C    Add C withAcc
F01C EB
XCHG     swap DE andHL pair contents
F01D 21, 50, 80
LXI H,8050H Load the destination address
F020 73
MOV M,E Store the lower order quotient
F021 23
INX H    Increase HLpair
F022 72
MOV M,D Store the higher order quotient
F023 23
INX H    Increase HLpair
F024 77
MOV M,A Store the remainder
F025 76
HLT Terminate the program


Output

Address Data
.
.
.
.
.
.
8050 6F
8051 02
8052 2E
.
.
.
.
.
.
Updated on: 2019-07-30T22:30:24+05:30

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements