Re: A83: Re: Re: Re: Problem with a program
[Prev][Next][Index][Thread]
Re: A83: Re: Re: Re: Problem with a program
That is a horrible way to do a 16-bit counter for a loop. Observe the
following:
ld bc,$FFFF ;Number of loops
Loop:
push bc ;Usually have to do this
...
pop bc
dec bc
ld a,c
or b
jr nz,Loop
Laurens Holst wrote:
>
> > 65,535 even =)
> >
> > Actually, you could just use a 16-bit register to control a DJNZ loop (you
> > CAN do that can't you?...lol) and do all the tough mathematics in the OP
> > registers. Generating 100,000 random numbers on an 8Mhz chip will be slow
> no
> > matter :)
>
> The Z80 in the TI-82/83(+)/85/86 runs at 6MHz, not 8.
>
> And DJNZ is 16-bit.
> But using a trick (see below), you can make 16-bit loops which are almost as
> fast as DJNZ.
>
> Trick: input=nr. of loops in BC
>
> ld a,c ;preloop-part
> ld c,b
> ld b,a
> dec bc
> inc b
> inc c
> Loop: ;the loop itself
> xxx
> xxx
> xxx
> djnz Loop
> dec c
> jr nz,Loop
>
> Ofcourse you can shorten this by precalculating BC.
>
> ~Grauw
--
Scott "_Wrath_" Dial
wrath@calc.org
ICQ#3608935
TimeCity AI Guy II - www.timecity.org
Member of TCPA - tcpa.calc.org
__________________________________________
NetZero - Defenders of the Free World
Get your FREE Internet Access and Email at
http://www.netzero.net/download/index.html
References: