needle = x1001010 10101001 10100xxx (x represents bits we are not interested in)
####
haystk = xxxxx001 10001101 01110010 10101010 01101001 01100011 10011001 00010001 .....
##
##
U64 bsSearch( U64 *hay, U8 oHay, U64 lHay, U64 *ndl, U8 oNdl, U64 lNdl ) {
...
}
##
##
haystk = xxxxx001 10001101 01110010 10101010 01101001 01100011 10011001 00010001 .....
needle = x10010 10101010 0110100x xx (note the alignment change!)
return = 01234567 89012345 6789 = 19th bit
= unit 2/ bit 3
##
##
REX.W + 0F A5 SHLD r/m64, r64, CL B Valid N.E. Shift r/m64 to left CL places while shifting bits from r64 in from the right.
REX.W + 0F AD SHRD r/m64, r64, CL B Valid N.E. Shift r/m64 to right CL places while shifting bits from r64 in from the left.
##
##
unsigned __int64 __shiftleft128( unsigned __int64 LowPart, unsigned __int64 HighPart, unsigned char Shift );
unsigned __int64 __shiftright128( unsigned __int64 LowPart, unsigned __int64 HighPart, unsigned char Shift );
##
##
for( i = 0; i < ( lHay % 64 )+1; ++i ) {
r1 = *( hay + i ); r2 = *( hay + i + 1 );
for( b1 = 0; b1 < 64; ++b1 ){
__shiftleft128( r2, r1, 1 );
}
}
##
##
for( j = 0; j < ( lNdl % 64 )+1; ++j ) {
r3 = *( ndl + j ); r4 = *( ndl +j + 1 );
for( b2 = 0; b2 < 64; ++b2 ) {
__shiftleft128( r4, r3, 1 );
}
}
##
##
U64 bsSearch( U64 *hay, U8 oHay, U64 lHay, U64 *ndl, U8 oNdl, U64 lNdl ) {
register U64 r1, r2, r3, r4;
U64 i, j, rv;
U8 b1, b2;
...
return rv;
}