Re: A86: Sorry Dux. =-|
[Prev][Next][Index][Thread]
Re: A86: Sorry Dux. =-|
Joshua J Seagoe wrote:
> >
> >Joshua J Seagoe wrote:
> >
> >> oh, picky, picky. sure it works, you just have to put the number in
> >b
> >> backwards...
>
> wait, could you do it backwards? would this work? this would make the
> main loop smaller.
It can't be done backwards :-) It wouldn't be faster if you did, because
you would end up looping more times than needed. You always need one value
shifting right and one value shifting left. The value shifting left must
be 16-bit and preferably the larger of the two (for speed).
>
>
> ;hl=de*b
> xor a ;clear stuff
> ld h,a
> ld l,a
> cp b
> ret z ;return with hl=0 if b=0
> preshift: ;first shift until we get the high bit
> sla b ;we're gonna do it backwards!
> jr nc,preshift
> add hl,de ;found the high bit
> mainloop:
> sla b ;remember, backwards!
> jr nc, skipadd ;from the african swallow
> add hl,de
> skipadd:
> add hl,hl
> ret z ;this could be wrong...
> jr mainloop
>
> -josh
>
> _____________________________________________________________________
> You don't need to buy Internet access to use free Internet e-mail.
> Get completely free e-mail from Juno at http://www.juno.com
> Or call Juno at (800) 654-JUNO [654-5866]
Follow-Ups:
References: