A83: Re: Re: Divide HL by DE


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

A83: Re: Re: Divide HL by DE




If you don't mind dividing HL by an 8-bit number, there is always the DivHLByA ROM call --
HL = int(HL/A) and A = mod(HL/A) after the result is called. I'm not too sure how fast it
is...

James.

----- Original Message -----
From: David Phillips <david@acz.org>
To: <assembly-83@lists.ticalc.org>
Sent: Thursday, March 09, 2000 1:00 AM
Subject: 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.
>
>
>
>



References: