- 2070 Magh · 8 marks
8085 ALP: divide two bytes
Short answer
Divide by repeated subtraction of the divisor from the dividend; each successful subtraction increments the quotient. The remaining dividend is the remainder. If divisor is zero, store FFH in both result locations. For 100÷7, quotient = 0EH, remainder = 02H.
Write an assembly language program in 8085 to divide a byte stored in memory location 9070 H by byte stored in 9071 H and store the remainder and quotient at 9072 H and 9073 H respectively.
Method: repeated subtraction. The divisor is subtracted from the dividend as long as the dividend is not smaller than the divisor; each successful subtraction increments the quotient. What is left is the remainder. A divide-by-zero check is included to prevent an endless loop.
LXI H,9070H
MOV A,M ; A = dividend (9070H)
INX H
MOV B,M ; B = divisor (9071H)
INR B
DCR B ; test divisor for zero
JZ ERROR
MVI C,00H ; C = quotient
LOOP: CMP B ; CY = 1 if A < B
JC DONE
SUB B ; subtract divisor
INR C ; count it
JMP LOOP
DONE: INX H ; HL = 9072H
MOV M,A ; remainder
INX H
MOV M,C ; quotient at 9073H
HLT
ERROR: INX H ; divide by zero: store FFH in both
MVI M,0FFH
INX H
MVI M,0FFH
HLT
Example: 9070H = 64H (100), 9071H = 07H gives quotient 0EH (14) at 9073H and remainder 02H at 9072H.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- 8085 ALP: interchange two bits of bytes · Microprocessor, chapter 2
- 8085 ALP: exchange bits D6 and D2 · Microprocessor, chapter 2
- 8085 ALP: square of ten numbers · Microprocessor, chapter 2
- 8085 ALP: compare two tables of 16-bit data · Microprocessor, chapter 2
- 8085 ALP: add two tables, sum and carry · Microprocessor, chapter 2
- 8085 ALP: transfer data with more than 3 ones · Microprocessor, chapter 2
- Interfacing: 512-byte RAM with 8085 · Instrumentation II, chapter 2
- C program: sum of two 8-bit BCD numbers · Embedded System, chapter 9
- Short note: Stored program control · Telecommunications, chapter 4
- PCM switching and stored program control · Telecommunications, chapter 4