As Rob Kennedy said, here you have features for the 32-bit and 64-bit Delphi development environment.
function GetBitCount(num: integer): integer;
asm
POPCNT eax, num
end;
function GetBitCount(num: Int64): integer;
asm
POPCNT rax, num
end;
EDIT: This is a 32-bit and 64-bit version compatible with Delphi.
{$IF CompilerVersion < 23}
NativeInt = integer;
{$IFEND}
function GetBitCount(num: NativeInt): integer;
asm
{$IFNDEF CPUX64}
POPCNT eax, num
{$ELSE CPUX64}
POPCNT rax, num
{$ENDIF CPUX64}
end;
source
share