Re: LZ: A new programming question
[Prev][Next][Index][Thread]
Re: LZ: A new programming question
Nathan Adams wrote:
>
> I have question about memory. Say I have the letters a through e stored in
> memory locations $80DF through $80E3 and I want to delete the b stored in
> $80E0 and then shift the contents of the rest of the memory that I have used
> to take up the slack so it would look something like this:
>
> (This isn't assembly language, just a table of values)
> Before: After:
> $80DF = a $80DF = a
> $80E0 = b $80E0 = c
> $80E1 = c $80E1 = d
> $80E2 = d $80E2 = e
> $80E3 = e $80E3 = nothing
>
> Is there a short and fast way of doing this?
> Nathan Adams
> nathana@goodnet.com
> "It is better to remain silent and be thought a fool,
> than to speak out and remove all doubt."
There is one asm command you could use, ldir. It means load hl into de
while increasing addresses until bc equals 0. so...
ld hl,$80E1 ;source of stuff
ld de,$80E0 ;destination of stuff
ld bc,$0003 ;amount of stuff, or bytes you want to move
ldir
By the way, there is no chance of overlapping problems. This routine is
especially good if you're moving lots and lots of bytes, like some
programs do to load pictures from graph mem to video mem. You can have
the fun of working out the other things, like how to calculate bc(bytes
to move), and stuff like that.
--
Compliments of:
_-_-_-_-_-_-_-_
Alan Bailey
mailto:bailala@mw.sisna.com
IRC:Abalone
Web:http://www.mw.sisna.com/users/bailala/home.htm
References: