[fpc-pascal] Move with pointers to memory
Rainer Stratmann
rainerstratmann at t-online.de
Wed Nov 13 09:36:59 CET 2013
http://www.freepascal.org/docs-html/rtl/system/move.html
I have a working function in assembler wich copys a memory block from sorce to
destination.
Now I want it to do with the move function from unit system, but it does not
work.
procedure wd_copy( s , d : pointer ; l : longint );
begin
move( s , d , l ); // does not work! Access violation errors
end;
procedure wd_copy( s , d : pointer ; l : longint );
begin
if l > 0 then begin
if d < s then begin
asm
pushf
mov esi,s
mov edi,d
mov ecx,l
cld // vorwärts
rep movsb
popf
end['EAX','EBX','ECX','EDX','ESI','EDI'];
end
else begin
asm
pushf
mov esi,s
add esi,l
dec esi
mov edi,d
add edi,l
dec edi
mov ecx,l
std // rückwärts
rep movsb
popf
end['EAX','EBX','ECX','EDX','ESI','EDI'];
end;
end;
end;
More information about the fpc-pascal
mailing list