Procedure XorMemPrim(var Mem1; const Mem2; Count : Cardinal); Var i:integer; p1,p2:pointer; Begin p1:=@Mem1; p2:=@Mem2; for i:=1 to count div 4 do begin pdword(p1)^:=pdword(p1)^ xor pdword(p2)^; p1:=p1+4; p2:=p2+4; end; For i:=1 to count mod 4 do begin pbyte(p1)^:=pbyte(p1)^ xor pbyte(p2)^; p1:=p1+1; p2:=p2+1; end; End;
Ludo > procedure XorMemPrim(var Mem1; const Mem2; Count : > Cardinal); register; asm > push esi > push edi > > mov esi, eax //esi = Mem1 > mov edi, edx //edi = Mem2 > > push ecx //save byte count > shr ecx, 2 //convert to dwords > jz @Continue > > cld > @Loop1: //xor dwords at a time > mov eax, [edi] > xor [esi], eax > add esi, 4 > add edi, 4 > dec ecx > jnz @Loop1 > > @Continue: //handle remaining bytes (3 or less) > pop ecx > and ecx, 3 > jz @Done > > @Loop2: //xor remaining bytes > mov al, [edi] > xor [esi], al > inc esi > inc edi > dec ecx > jnz @Loop2 > > @Done: > pop edi > pop esi > end; > > Thanks in advance, > -- > Leonardo M. Ramé > http://leonardorame.blogspot.com > > -- > _______________________________________________ > Lazarus mailing list > [email protected] > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
