RE: LZ: A new programming question


[Prev][Next][Index][Thread]

RE: LZ: A new programming question



On Wed, 18 Dec 1996 09:41:10 -0700,
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?

Use the ldir command.  To use this, load the address of the memory location 
you wish to move the values from into hl, then load the address of where 
you want them moved to into de.  Set bc equal to the number of values you 
wish to move.  Example (using your case):

ld    de, $80E0   ;location of variable to be deleted
ld    hl, $80E1   ;location of next variable after deleted variable
ld    bc, $0003   ;You are moving three values
ldir
ex    de, hl      ;switch de, hl
ld    (hl), $00   ;will set the last memory location ($80E3) = $00

I think that this will work.  If you don't care whether $80E3 has a value 
in it or not, then leave the last two lines out.

Hope it helped,
Michael Wyman - SeaHorse Software
wyma0012@gold.tc.umn.edu