In this program, we will write an 8085 Program to Divide 16-bit number by 8-bit number in the 8085 microprocessor with a program flow chart and explanation of the program.
8085 Program to Divide 16-bit number by 8-bit number
Program Statement
Divide the 16-bit number stored in memory locations D000H and D001H by the 8-bit number stored at memory location D002H. Store the quotient in memory locations E000H and E001H and the remainder in memory locations E002H and E003H.
Explanation of Program
- Get the dividend in the HL register pair. Get the divisor in the accumulator and store in register C.
- Initialize quotient in register pair DE as 00 H.
- Perform the division by subtracting the divisor from the dividend, till the dividend is greater than the divisor. Increment the quotient every time the dividend is greater than the divisor when the subtraction is performed.
- When the dividend becomes less than the divisor then this dividend is the reminder. Store the quotient and remainder.
Example: D000H = 05 H, D001H = 02 H, D002H = 04 H
Result = 0205H / 04H = 81 H (Quotient) and 01H = Remainder
E000H = 81H, E001H = 00H, E002H = 01H, E003H = 00H
Flow Chart of Program
Assembly Language Program
Label | Instruction | Comment | Operation |
---|---|---|---|
LHLD D000H | Get the dividend | H = 02H, L = 05H | |
LDA D002H | Get the divisor | A = 04H | |
MOV C, A | Store the divisor in C | C = 04H | |
LXI D, 0000H | Initialize Quotient = 0 | D = 00H, E = 00H | |
BACK: | MOV A, L | A = L | |
SUB C | Division = Dividend – Divisor | A = A – C | |
MOV L, A | L = A | ||
JNC SKIP | |||
DCR H | Subtract borrow of previous subtraction | H = H – 1 | |
SKIP: | INX D | Quotient = Quotient + 1 | DE = DE + 1 |
MOV A, H | A = H | ||
CPI 00 | Check if dividend < divisor | ||
JNZ BACK | |||
MOV A, L | if no repeat | A = L | |
CMP C | |||
JNC BACK | |||
SHLD E002H | Store the remainder | E002H = 01H E003H = 04H | |
XCHG | |||
SHLD E000H | Store the Quotient | E000H = 81H E001H = 00H | |
HLT | Terminate program execution | Stop |