Divide 16-bit number with 8-bit number using shifting technique

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
37-Divide 16-bit number with 8-bit number using shifting technique

Post a Comment

0 Comments

Close Menu