[Lazarus] Convert assembler to Pascal
Leonardo M. Ramé
l.rame at griensu.com
Tue Sep 13 14:42:25 CEST 2011
Hi, I'm trying to convert Rijndael encryption method from TPLockBox to
Lazarus/FPC.
While converting the code, I found this routine in Assembler. I'm
wondering if somebody can help me convert this to Pascal?.
Here's the routine:
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
More information about the Lazarus
mailing list