Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2004-03

problem with MOVE

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Darek Mazur

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

Reply by email

darek
to Darek Mazur

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

Earlier message 74 lines
----- Original Message ----- From: "Darek Mazur" To: 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 - > http://lists.freepascal.org/mailman/listinfo/fpc-devel >

Reply by email