这不难,也不用做循环:
Data: array of byte;
const buf:array[0..49]of byte
=($0,$0,$0,$0,$0,$1,
$0,$0,$0,$0,$0,$0,$20,$43,$4b,
$41,$41,$41,$41,$41,$41,$41,$41,
$41,$41,$41,$41,$41,$41,$41,$41,
$41,$41,$41,$41,$41,$41,$41,$41,
$41,$41,$41,$41,$41,$41,$0,$0,$21,$0,$1);
//注意ByteBeginNum,ByteEndNum从0到49。比特从0到7
procedure GetData(ByteBeginNum,ByteEndNum,BitBeginPos,BitEndPos: integer);
begin
SetLength(Data,ByteEndNum - ByteBeginNum+1);
data[0] := buf[ByteBeginNum] and ($FF shr BitBeginPos);
CopyMemory(@data[1],@buf[ByteBeginNum+1],ByteEndNum - ByteBeginNum-1);
data[ByteEndNum - ByteBeginNum] := buf[ByteEndNum] and ($FF shl BitEndPos);
end;