function ExtractBits(const Value, Start, Count: Integer): Integer;
const
Mask: array[0..31] of Integer =
($01,$03,$07,$0F,$1F,$3F,$7F,$FF,
$01FF,$03FF,$07FF,$0FFF,$1FFF,$3FFF,$7FFF,$FFFF,
$01FFFF,$03FFFF,$07FFFF,$0FFFFF,
$1FFFFF,$3FFFFF,$7FFFFF,$FFFFFF,
$01FFFFFF,$03FFFFFF,$07FFFFFF,$0FFFFFFF,
$1FFFFFFF,$3FFFFFFF,$7FFFFFFF,$FFFFFFFF);
asm
xchg ECX,EDX
test EDX,EDX
jnz @@isoke
xor EAX,EAX
jmp @@ending
@@isoke:
dec EDX
and EDX,31
shr EAX,cl
and EAX,dword ptr [Mask+EDX*4]
@@ending:
end;