Statement:Divide 16 bit number stored in memory locations 2200H and 2201H by the 8 bit number stored at memory location 2202H. Store the quotient in memory locations 2300H and 2301H and remainder in memory locations 2302H and 2303H
Sample problem
(2200H) = 60H
(2201H) = A0H
(2202H) = l2H
Result = A060H/12H = 8E8H Quotient and 10H remainder
(2300H) = E8H
(2301H) = 08H
(2302H= 10H
(2303H) 00H
Source program
LHLD 2200H : Get the dividend
LDA 2202H : Get the divisor
MOV C, A
LXI D, 0000H : Quotient = 0
BACK: MOV A, L
SUB C : Subtract divisor
MOV L, A : Save partial result
JNC SKIP : if CY 1 jump
DCR H : Subtract borrow of previous subtraction
SKIP: INX D : Increment quotient
MOV A, H
CPI, 00 : Check if dividend <>
No comments:
Post a Comment