[fpc-devel]problem with MOVE -more

darek darek at emadar.com
Sat Mar 20 22:55:27 CET 2004


Once more  about problem with Move

I have simple procecedure with 4 lines

-------------------
      writeln('choice a0 '+long2str(longint(item))+'
'+long2str(longint(item2))+' '+long2str(size)+'
'+long2str(longint(@item2))+' '+long2str(longint(@item)));

     movefast(item^,item2^,6);
     movefast(item^,item2^,6);
     writeln ('choice aa '+long2str(longint(item))+'
'+long2str(longint(item2))+' '+long2str(size));
--------------------
function movefast is the same like move:
procedure MoveFast(const Src; var Dest; count : Integer);
begin
  writeln('movefast',longint(@src):9,longint(@dest):9,count:9);
  move(src,dest,count)
end;
------------------
I recieve :

choice a0 10242256 10242928 654 10242024 10242020
movefast 10242256 10242016        6
;                               ^^^^^^^^^^^ it should be item2= 10242928
movefast 10223616 10242016        6
eeee  choice aa 10227216 10242928 654

Why


Darek



----- Original Message -----
From: "Darek Mazur" <darekm at emadar.com>
To: <fpc-devel at lists.freepascal.org>
Sent: Saturday, March 20, 2004 10:06 PM
Subject: [fpc-devel]problem with MOVE


> Hi
>  I have problem with function move(src,dest,count)
>
> sometimes they erase value of SRC
>
> if I run
>
>
>      move(item^,item2^,10);
> then
>    value of   item (not item^) is set to 0 (nil)
>
> Its hard to debug it for me, only thing I discover is so:
>
> for modified procedure
>
> --------------------------------------------
> procedure MoveNN(const source;var dest;count:longint);assembler;
> var
>   saveesi,saveedi : longint;
> asm
>         movl    %edi,saveedi
>         movl    %esi,saveesi
> {$ifdef REGCALL}
>
>         movl    %eax,%esi   {source}
>         movl    %edx,%edi   {dest}
>         movl    %ecx,%edx
> {$else}
> (*        movl    dest,%edi
>         movl    source,%esi
>         movl    count,%edx
> *)
> {$endif}
> { Forward Copy }
> .LFMove:
>         cld
> //          std
>
>         movl    %edx,%ecx
>         rep
>         movsb
>         jmp .LMoveEnd
> { Backward Copy }
> .LBMove:
> (*
> *)
> .LMoveEnd:
>         movl    saveedi,%edi
>         movl    saveesi,%esi
>
> end;
>
> ------------------------------
> bug is present
> I thing that somethis wrong is with CLD (or passing parameters)
> HINT: ITEM is set to 0 when count if >4
>
>
> please help
>
> Darek
>
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
>





More information about the fpc-devel mailing list