Hi,
What about this?
ld hl,DATA_AREA
ld (hl),0
ld de,DATA_AREA+1
ld bc,4095
ldir
Regards,
Tony Bedford wrote:
>
> Hi,
>
> I have a loop that needs to clear a 4096 byte area.
> I would like it to be as fast as possible, but this is
> not critical.
>
> Here's what I came up with:
>
> ; need to clear data area
> ; data area is 4096 bytes
> ; 4096 = (255*16)+16
>
> ld hl,DATA_AREA
> ld c,16
>
> @@start_loop1:
>
> ld b,255
> @@clear_byte:
> ld (hl),0
> inc hl
> djnz @@clear_byte
>
> dec c
> jp nz,@@start_loop1
>
> ld b,16
> @@start_loop2:
> ld (hl),0
> inc hl
> djnz @@start_loop2
>
> It appears to work OK, but surely there must be a
> simpler way or a faster way?
>
> Any suggestions? Does anyone know of any good docs on Z80 code
> optimisation?
>
> Thanks,
> Tony
> --
> For info, see http://www.stack.nl/~wynke/MSX/listinfo.html
--
[EMAIL PROTECTED] - http://www.aamsx.org
--
For info, see http://www.stack.nl/~wynke/MSX/listinfo.html