U64 nextBit( U64 **p, U8 *o ) { // p: pointer to pointer to current quad; o: pointer to current offset
if( ++( *o ) == 64 ) { // increment the offset and detect transitions across quad boundaries.
*o = 0; // reset the offset.
++*p; // increment the quad pointer.
}
// Get the 'current' (unshifted) quad value; and the next
return __shiftleft128( *( *p + 1 ), **p, *o ); // return the value from the higher location with *o bits from lo shifted in from the right.
}
####
mov rax, QWORD PTR [r11+r9+16]
mov r8, QWORD PTR [r11+r9+8]
##
##
; 41 : while( hay < eHay ) { // until we reach the end of the haystack
cmp rcx, r12
jae SHORT $LN5@bvSearch
mov r11, rcx
sub r11, r9
npad 3
$LL6@bvSearch:
; 42 : hp = hay; // copy of the haystack pointer
; 43 : np = ndl; // copy of the needle pointer
mov r9, r13
$LL4@bvSearch:
; 44 : //TAG;
; 45 : do {
; 46 : // end of needle; match completed; return current value of haystack pointer
; 47 : if( np >= eNdl ) {
cmp r9, rdi
jae SHORT $LN19@bvSearch
; 55 : }
; 56 : h = nextQuad( &hp, oHay ); // get the next quad from haystack
mov rax, QWORD PTR [r11+r9+16]
mov r8, QWORD PTR [r11+r9+8]
; 57 : n = nextQuad( &np, oNdl ); // get the next quad from needle
mov rdx, QWORD PTR [r9+8]
add r9, 8
movzx ecx, sil
shld r8, rax, cl
mov rax, QWORD PTR [r9+8]
movzx ecx, bpl
shld rdx, rax, cl
; 58 : //printf( "\rhp:%p->h:%16I64x[%s] np:%p->n:%16I64x[%s]\t", hp, h, toBin( h ), np, n, toBin( n ) );
; 59 : } while( h == n ); // while the quads match
cmp r8, rdx
je SHORT $LL4@bvSearch
; 60 : nextBit( &hay, &oHayCopy ); // Got here means a mismatch; get the next bit from the haystack
inc bl
cmp bl, 64 ; 00000040H
jne SHORT $LN14@bvSearch
xor bl, bl
add r10, 8
add r11, 8
; 41 : while( hay < eHay ) { // until we reach the end of the haystack
cmp rcx, r12
jae SHORT $LN5@bvSearch
mov r11, rcx
sub r11, r9
npad 3
$LL6@bvSearch:
; 42 : hp = hay; // copy of the haystack pointer
; 43 : np = ndl; // copy of the needle pointer
mov r9, r13
$LL4@bvSearch:
; 44 : //TAG;
; 45 : do {
; 46 : // end of needle; match completed; return current value of haystack pointer
; 47 : if( np >= eNdl ) {
cmp r9, rdi
jae SHORT $LN19@bvSearch
; 55 : }
; 56 : h = nextQuad( &hp, oHay ); // get the next quad from haystack
mov rax, QWORD PTR [r11+r9+16]
mov r8, QWORD PTR [r11+r9+8]
; 57 : n = nextQuad( &np, oNdl ); // get the next quad from needle
mov rdx, QWORD PTR [r9+8]
add r9, 8
movzx ecx, sil
shld r8, rax, cl
mov rax, QWORD PTR [r9+8]
movzx ecx, bpl
shld rdx, rax, cl
; 58 : //printf( "\rhp:%p->h:%16I64x[%s] np:%p->n:%16I64x[%s]\t", hp, h, toBin( h ), np, n, toBin( n ) );
; 59 : } while( h == n ); // while the quads match
cmp r8, rdx
je SHORT $LL4@bvSearch
; 60 : nextBit( &hay, &oHayCopy ); // Got here means a mismatch; get the next bit from the haystack
inc bl
cmp bl, 64 ; 00000040H
jne SHORT $LN14@bvSearch
xor bl, bl
add r10, 8
add r11, 8
$LN14@bvSearch:
; 40 :
; 41 : while( hay < eHay ) { // until we reach the end of the haystack
cmp r10, r12
jb SHORT $LL6@bvSearch
$LN5@bvSearch:
; 61 : }