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

MicrocontrollerMicroprocessor8085

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

AddressData
.
.
.
.
.
.
80002B
8001CA
800253
.
.
.
.
.
.


Flow Diagram

Program

AddressHEX CodesLabelsMnemonicsComments
F00021, 00, 80
LXI H,8000HPoint 8000Haddress
F0037E
MOV A, MStore the lower order byte
F00423
INX H   Increase the HL pair to point next loc
F00546
MOV B, MStore the higher order byte
F00623
INX H   Increase the HL pair to point next loc
F0074E
MOV C, MLoad the denominator
F00804
INR BIncrease B register
F00921, 00, 00
LXI H,0000HStore 0000Hinto HL pair
F00C91LOOPSUB C   Subtract C from acc
F00DDA, 14, F0
JC SKIP    Jump to SKIPwhen CY = 1
F01023INCRINX H   Increase quotient part
F011C3, 0C, F0
JMP LOOP   Jump to LOOP
F01405SKIPDCR B   Decrease B
F015CA, 1B, F0
JZ STORE    Jump to STOREwhen Z = 1
F018C3, 10, F0
JMP INCR    Jump to INCR
F01B81STOREADD C   Add C withAcc
F01CEB
XCHG    swap DE andHL pair contents
F01D21, 50, 80
LXI H,8050HLoad the destination address
F02073
MOV M,EStore the lower order quotient
F02123
INX H   Increase HLpair
F02272
MOV M,DStore the higher order quotient
F02323
INX H   Increase HLpair
F02477
MOV M,AStore the remainder
F02576
HLTTerminate the program


Output

AddressData
.
.
.
.
.
.
80506F
805102
80522E
.
.
.
.
.
.
raja
Published on 21-Jan-2019 14:37:48
Advertisements