A82: Dividing and remainders


[Prev][Next][Index][Thread]

A82: Dividing and remainders



There is a routine included with the Ark v1.1 source that divides a by b 
(a/b). My question is when you divide say 8/3 what happens to the 
remainder and if I just wanted the interger value what would I do. And 
if anyboby has another way to divide numbers please post this 
routine.(isn't there something in your z80 books dines?).
I tried to attach the routines below to look at. If it isn't there oh 
well!
; Math routines for the Z80 microprocessor
; by Randy Gluvna
; gluvna@home.com
; http://members.home.com/gluvna

MULT:
        PUSH BC
        DEC B
        LD C,A
MULT_LOOP:
        ADD A,C
        DJNZ MULT_LOOP
        POP BC
        RET                  
DIV:
        PUSH DE
        LD D,0
DIV_LOOP:
        INC D
        SUB B
        OR A
        JP P,DIV_LOOP
        LD A,D
        POP DE
        DEC A
        RET

Follow-Ups: