Re: A86: Division in assembly
[Prev][Next][Index][Thread]
Re: A86: Division in assembly
ariwsi@juno.com wrote:
>
> On Tue, 16 Sep 1997 15:29:51 -0700 DeComPro@dnc.net (David Buttolph)
> writes:
>
> >Can someone tell me how to divide in z80 assembly, it's not DIV is it?
>
> The following routine will divide C into HL, storing the quotient
> in HL and the remainder in A:
>
> Divide: ;C = divisor, HL = dividend
> XOR A
> LD B,$10
> divloop:
> ADD HL,HL
> RLA
> CP C
> JR C,too_low
> SUB C
> INC L
> too_low:
> DJNZ divloop
> RET ;A = remainder, HL = quotient
> ; Cycles = 715 - 763
its simpler to use the OPs because then you can display them more easily
(thats probably what he wants to do)
References: