Re: A86: Re: Re: Division
[Prev][Next][Index][Thread]
Re: A86: Re: Re: Division
--- David Phillips <david@acz.org> wrote:
>
> I almost forgot, Joshua Grams posted this routine a
> while ago, and it's
> really fast:
>
> ;=========================================
> ; Divide (d = d / c ... a = d % c)
> ; by Joshua Grams <j3grams@earthling.net>
> ; input: d = dividend, c = divisor
> ; output: d = quotient, a = remainder
> ; total: 15b/355t to 363t (exluding RET)
> ;=========================================
> Divide:
> push bc ; save bc
> sub a ; clear a
> ld b,8 ; 8 shifts
> DivideL:
> sla d ; shift left d
> rla ; into a
> cp c ; is a >= c
> jr c,DivideS ; skip if not
> sub c
> inc d ; a = a-c, set bit in d
> DivideS:
> djnz DivideL ; loop
> pop bc ; restore bc
> ret ; done
>
This looks really good, but does anyone have any ideas
how I could go about converting this to 16 bit?
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com