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.
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.
THE ANSWER IF THE DIVIDEND IS FFFF AND THE DIVISOR IS 01 IS WRONG
ReplyDeleteMinmax Principle
ReplyDeleteToken Ring Algorithm in Mutual Exclusion
Nicholl Lee Nicholl Line Clipping
Symbolic Reasoning
Input Buffering
Naive String Matching Algorithm
Direct File Organization
Filled-Area Primitives
RMMM
Dynamic Arbitration Algorithms
ReplyDeleteData Structures
Steepest-Ascent Hill Climbing
Forward References | Back-Patching
Transaction State Diagram
Depth Buffer Method / Z-Buffer Method
Algorithm: Single-pass assembler | Intel 8088
Matrix Representation and homogeneous coordinates