/// near-direct method: rotations with moving mask
unsigned rbN4 (unsigned arg)
{
__asm
{
mov edx, arg // edx := arg
mov esi, 10001H // moving mask, starting with 00010001H
rol edx, 1 // first rotation
mov eax, esi // copy mask to do & in-place
and eax, edx // apply mask
mov ecx, 15 // 15 iterations ahead
NEXT: // loop begin
rol esi, 1 // next mask
rol edx, 2 // next rotation
mov ebx, esi
and ebx, edx
or eax, ebx // store next two bits
sub ecx, 1
jnz NEXT // while ecx != 0
}
// return eax
}