March 2010
Beginner
760 pages
18h 51m
English
Another common bit string operation is producing a single bit string by merging, or interleaving, bits from two different sources. The following example code sequence creates a 32-bit string by merging alternate bits from two 16-bit strings:
// Merge two 16-bit strings into a single 32-bit string.
// ax - Source for even numbered bits.
// bx - Source for odd numbered bits.
// cl - Scratch register.
// edx- Destination register.
mov( 16, cl );
MergeLp: shrd( 1, eax, edx ); // Shift a bit from eax into edx.
shrd( 1, ebx, edx ); // Shift a bit from ebx into edx.
dec( cl );
jne MergeLp;This particular example merged two 16-bit values together, alternating their bits in the result value. For a faster implementation of this ...