Closed Thaddy closed 3 months ago
I am not a great coder, for FreePascal/Lazarus I used the following as a workaround.
assembler;
{$ifdef CPUx86_64}
{$ASMMODE intel}
Note the CPUx86_64 was previously CPUx64. It clears the compiler error for cocosets. https://wiki.freepascal.org/Asm REF: https://www.freepascal.org/docs-html/prog/progsu3.html
These pure Pascal versions work for me. Sorry for not replying until now, I had notifications turned off by mistake.
const
BitsPerInt = SizeOf(Integer) * 8;
function TCocoSet.GetBit(Index: Integer): Boolean;
var
LRelInt: PInteger;
LMask: Integer;
begin
if (Index >= FSize) or (Index < 0) then
Error;
LRelInt := FBits;
Inc(LRelInt, Index div BitsPerInt);
LMask := (1 shl (Index mod BitsPerInt));
Result := (LRelInt^ and LMask) <> 0;
end;
procedure TCocoSet.SetBit(Index: Integer; Value: Boolean);
var
LRelInt: PInteger;
LMask: Integer;
begin
if Index < 0 then
Error;
if Index >= FSize then
SetSize(Index + 1);
LRelInt := FBits;
Inc(LRelInt, Index div BitsPerInt);
LMask := (1 shl (Index mod BitsPerInt));
if Value then
LRelInt^ := LRelInt^ or LMask
else
LRelInt^ := LRelInt^ and not LMask;
end;
The above changes are included in latest revision.
The fact that the the set unit contains two assembler routines prevents me from making it cross-platform (arm etc) The rest of the units are already p[orted to Freepascal. Can you provide pure pascal versions?