Make your own free website on Tripod.com

DIV168     LD   A,(DVSAD)       LOAD DIVISOR
           LD   D,A             INTO D
           LD   E,0
           LD   HL,(DVDAD)      LOAD 16-BIT DIVIDEND
           LD   B,8             INITIALIZE COUNTER
DIV        XOR  A               CLEAR C BIT
           SBC  HL,DE           DIVIDEND - DIVISOR
           INC  HL              QUOTIENT = QUOTIENT + 1
           JP   P,NOADD         TEST IF REMAINDER
                                POSITIVE
           ADD  HL,DE           RESTORE IF NECESSARY
           DEC  HL              QUOTIENT = QUOTIENT - 1
NOADD      ADD  HL,HL           SHIFT DIVIDEND LEFT
           DJNZ DIV             LOOP UNTIL B = 0
           RET