Statement: Divide the 16-bit unsigned number in memory locations 2200H and 2201H (most significant bits in 2201H) by the B-bit unsigned number in memory location 2300H store the quotient in memory location 2400H and remainder in 2401H.
| Assumption: The most significant bits of both the divisor and dividend are zero.
| Source program :
- MVI E, 00 : Quotient = 0
- LHLD 2200H : Get dividend
- LDA 2300 : Get divisor
- MOV B, A : Store divisor
- MVI C, 08 : Count = 8
- NEXT: DAD H : Dividend = Dividend x 2
- MOV A, E
- RLC
- MOV E, A : Quotient = Quotient x 2
- MOV A, H
- SUB B : Is most significant byte of Dividend > divisor
- JC SKIP : No, go to Next step
- MOV H, A : Yes, subtract divisor
- INR E : and Quotient = Quotient + 1
- SKIP:DCR C : Count = Count - 1
- JNZ NEXT : Is count =0 repeat
- MOV A, E
- STA 2401H : Store Quotient
- Mov A, H
- STA 2410H : Store remainder
- HLT : End of program.
| Flowchart for program | |
Related Programs : (Click down)
Count number of one's in a number
Subtract two 16-bit numbers.
Add contents of two memory locations
Find the square of given number