Re: A83: A routine to move data...


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

Re: A83: A routine to move data...




It won't work. The "ld hl,de-bc" command is illegal (this isn't high 
level language). The "sub (statvars),(statvars+2)" won't work either. 
You should do something like this:

ld a,(statvars)
cp (statvars+2)
jp z,the_end

You should also consider using the "ldir" command for moving large 
blocks of data. 

the "ldir" command repeats this code until bc=0:

   ld (de,hl)  ; note that this instruction is not valid
   inc de
   inc hl
   dec bc

So, to use it you'd have:
  bc=number of bytes to move
  de=new data
  hl=old data

>
>
>Does this work??
>
>SOURCE:
>;MOVEIT.Z80
>;by: Chris Watford
>;copying data plus deleting the old data
>;usage: moving data
>
>;input:
>;bc= Start of old data
>;de= End of old data
>;hl= Where to put it
>
>start:
> push bc
> push de
> push hl
>;I am getting the lenght of data
> ld hl,de-bc
> ld (statvars),hl
>;statvars now contains the length of the data
> pop hl
> pop de
> pop bc
> ld de,(statvars)
> ld (statvars+2),0
>loop:
> sub (statvars),(statvars+2) ;is the operation done??
> jp z,the_end
> ld (hl),(bc) ;copy old data
> ld (bc),0000h ;delete old data
> inc (statvars+2) ;increment the counter
> inc (bc)  ;
> inc (bc)  ;move to the next mem location
> jp loop  ;lets do more deleting and moving
>the_end:
> ret
>
>
>


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com