Hey.
Sorry for the bad English, I use Google translator.
The TGXByteBuffer.GetInt64 function returns an incorrect result due to the use of the Swap procedure.
For example, the value of Int64 (00 00 00 00 00 00 00 00 20) is returned as 0. I solved the problem by adding a new function from the Internet
function Swap64 (Value: Int64): Int64;
{$ IFDEF CPUX86}
var Lo, Hi: Cardinal;
begin
Lo: = Int64Rec (Value) .Hi;
Hi: = Int64Rec (Value) .Lo;
Int64Rec (Result) .Hi: = (Hi shr 24) or (Hi shl 24) or ((Hi and $ 00FF0000) shr 8) or ((Hi and $ 0000FF00) shl 8);
Int64Rec (Result) .Lo: = (Lo shr 24) or (Lo shl 24) or ((Lo and $ 00FF0000) shr 8) or ((Lo and $ 0000FF00) shl 8);
end;
{$ ENDIF CPUX86}
{$ IFDEF CPUX64}
asm
// -> RCX Value
// <- RAX Result
MOV RAX, RCX
BSWAP RAX
end;
{$ ENDIF CPUX64}
function TGXByteBuffer.GetInt64 (): Int64;
begin
System.Move (FData [FPosition], Result, 8);
Result: = Swap64 (Result); // in the original - Result: = Swap (Result);
FPosition: = FPosition + 8;
end;
I think it will be useful for those who are faced with the problem of getting Int64 values.
Hi,
Hi,
Thank you for this info. We'll check this.
BR,
Mikko