From: Skybuck Flying on
alt.lang.asm added.

Routines can be implemented in basm as well ;)

Bye,
Skybuck.

"Skybuck Flying" <spam(a)hotmail.com> wrote in message
news:2abf2$477cdbd7$541983fa$32366(a)cache1.tilbu1.nb.home.nl...
> Hello,
>
> I might need a routine to copy bits from a bit position to another bit
> position.
>
> For maximum speed to minimum version could be:
>
> // minimum overhead version:
> CopyBits(
> SourceBase : pointer; // byte/memory position
> SourcePosition : integer; // bit position from above.
> DestBase : pointer;
> DestPosition : integer;
> BitsToCopy : integer );
>
> For extra safety the extra overhead version could be:
>
> // extra overhead version:
> CopyBits(
> SourceBase : pointer;
> SourcePosition : integer;
> SourceSize : integer; // size of base in bytes
>
> DestBase : pointer;
> DestPosition : integer;
> DestSize : integer;
> BitsToCopy : integer );
>
> // the size parameters could be used to implement additional checks. like
> asserts or so.
>
> For now I might come away with a special prototype which copies bits from
> the source into a 32 bit variable:
>
> CopyBits(
> SourceBase : pointer;
> SourcePosition : integer;
>
> var Dest : integer;
>
> BitsToCopy : byte
> );
>
> Any implementation you can provide are appreciated and will be looked at !
> ;) :)
>
> Usage examples:
>
> // example 1:
> var
> InputArray : array of byte;
> OutputArray : array of byte;
> begin
> SetLength( InputArray, 1000 );
> SetLength( OutputArray, 1000 );
>
> CopyBits( @InputArray[0], 1235, @OutputArray[0], 3452, 700 );
>
> OutputArray := nil;
> InputArray := nil;
> end;
>
> // example 2:
> var
> InputArray : array of byte;
> OutputArray : array of byte;
> begin
> SetLength( InputArray, 1000 );
> SetLength( OutputArray, 1000 );
>
> CopyBits( @InputArray[0], 1235, 1000, @OutputArray[0], 3452, 1000,
> 700 );
>
> OutputArray := nil;
> InputArray := nil;
> end;
>
> // example 3:
> var
> InputArray : array of byte;
> Output : integer;
> begin
> SetLength( InputArray, 1000 );
>
> CopyBits( @InputArray[0], 1235, Output, 7 );
>
> InputArray := nil;
> end;
>
> Bye,
> Skybuck.
>