Freya wrote:
>It's beeen a long time, but I seem to remember that the command LDIR was
>really easy to use and very fast!??
LDIR is great for moving memory, but the loops described by Laurens are
general purpose.
Greetz,
Patriek
--
For info, see http://www.stack.nl/~wynke/MSX/listinfo
It's beeen a long time, but I seem to remember that the command LDIR was
really easy to use and very fast!??
love
Freya
- Original Message -
From: Laurens Holst <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 15, 2001 2:01 AM
Subject: Re: Large loop
> In general, for a loop with more than 256 steps, I use the following
> code:
>
> ld bc,ITERATIONS
> LOOP: push bc
> ...
> (whatever must be done ITERATIONS times)
> ...
> pop bc
> dec bc
> ld a,b
> or c
> jr nz,LOOP
Faster is:
ld b,ITERATIONS mod 256
ld c,(ITERATIONS-1) / 256 +1
LOOP:
{do
> > > ld hl,DATA_AREA
> > > ld de,DATA_AREA+1
> > > ld bc,4096-1
> > > ld (hl),0
> > > ldir
> >
> > Yes, it is the faster method to fill a memory area.
>
> It's surely the smallest way to fill a memory area,
> but I believe there is a faster method:
>
> ld hl,DATA_AREA
> ld de,DATA_AREA+1
> ld (hl
> ld hl,DATA_AREA
> ld de,DATA_AREA+1
> ld (hl),0
> rept 4095
> ldi
> endm
> I did use this loop expansion inside the core of
> Fudebrowser for DOS, but I believe Adriano wrote it out
> when porting to UZIX, due to lack of space. This trick
> is also used
Nestor wrote:
>
> > ld hl,DATA_AREA
> > ld de,DATA_AREA+1
> > ld bc,4096-1
> > ld (hl),0
> > ldir
>
> Yes, it is the faster method to fill a memory area.
It's surely the smallest way to fill a memory area,
but I believe there is a faster method:
ld hl,DATA_AREA
ld de,DA
> ld hl,DATA_AREA
> ld de,DATA_AREA+1
> ld bc,4096-1
> ld (hl),0
> ldir
Yes, it is the faster method to fill a memory area.
In general, for a loop with more than 256 steps, I use the following
code:
ld bc,ITERATIONS
LOOP: push bc
...
(whatever must be done ITERATIONS times)
...
pop bc
dec bc
ld