Hello,
I have found out that the TRORandom_LFSR does not work when compiled for 64bit (it just throws exception “not converted from asm” at run-time). I have analyzed the problem and created a pascal version of the missing pieces. It seems to work fine, please check.
uRORng.pas // modified parts
{$IFDEF CPU64}
procedure LFSRBuf(Self: Pointer; var Buffer; Size: Integer);
var
LInst: TRORandom_LFSR absolute Self;
LPtr: Integer;
LBuffer: PByte;
LValue: Word;
begin
// raise Exception.Create('not converted from asm');
// <CALLIDA>
if @Buffer = nil then Exit;
LBuffer:= PByte(NativeInt(@Buffer) + Size - 1);
LPtr:= LInst.FPtr;
while Size > 0 do begin
LValue:= LInst.FRegister[LPtr];
LBuffer^:= LValue;
LValue:= LInst.FTable[LValue];
LInst.FRegister[LPtr]:= LValue and $0FF;
Dec(LPtr);
if LPtr < 0 then LPtr:= LInst.FLast;
LInst.FRegister[LPtr]:= LInst.FRegister[LPtr] xor (LValue shr 8);
Inc(LPtr, 2);
if LPtr > LInst.FLast then
LPtr:= LPtr - LInst.FLast - 1;
Dec(Size);
Dec(LBuffer);
end;
LInst.FPtr:= LPtr;
// </CALLIDA>
end;
{$ELSE}
...
{$IFDEF CPU64}
procedure LFSRBuf128(Self: Pointer; var Buffer; Size: Integer);
var
LInst: TRORandom_LFSR absolute Self;
LPtr: Integer;
LBuffer: PByte;
LValue: Word;
begin
// raise Exception.Create('not converted from asm');
// <CALLIDA>
if @Buffer = nil then Exit;
LBuffer:= PByte(NativeInt(@Buffer) + Size - 1);
LPtr:= LInst.FPtr;
while Size > 0 do begin
LValue:= LInst.FRegister[LPtr];
LBuffer^:= LValue;
LValue:= LInst.FTable[LValue];
LInst.FRegister[LPtr]:= LValue and $0FF;
LPtr:= (LPtr - 1) and $0F;
LInst.FRegister[LPtr]:= LInst.FRegister[LPtr] xor (LValue shr 8);
LPtr:= (LPtr + 2) and $0F;
Dec(Size);
Dec(LBuffer);
end;
LInst.FPtr:= LPtr;
// </CALLIDA>
end;
{$ELSE}
...
procedure TRORandom_LFSR.SetSize(Value: Integer);
procedure CalcLFSRTable(XORCode: Byte);
var
I,J,Z: Integer;
LCode: Word;
begin
{$IFDEF CPU64}
// raise Exception.Create('not converted from asm');
// <CALLIDA>
LCode:= 0;
for I:= 0 to 7 do begin
LCode:= (LCode shl 1) or (XORCode and 1);
XORCode:= XORCode shr 1;
end;
XORCode:= LCode;
// </CALLIDA>
{$ELSE}
...
Regard from Prague,
Jaroslav