A83: Re: Divide HL by DE


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

A83: Re: Divide HL by DE




I think this routine is by Dux Gregis.  It divides DE by C.  There's one by
Jimmy Mardell that does full 16 bit signed division if you need more than
this:

Divide:
 xor a
 ld b,16  ;16 shifts
@dloop:
 sla e
 rl d    ;shift DE left
 rla    ;into A
 cp c    ;if A<=C
 jr c,skip
 sub c   ;then A= A-C
 inc e   ;set bit 0
@skip:
 dec b
 jr nz,@dloop
 ret


> Does anyone have a simple routine to divide HL by DE on the 83+?  Speed is
> more important than size in this case.




Follow-Ups: References: