shuffling bits
If you need to do many swizzles the BT and ADC/RCL/RCR instructions are
the way to go in general - use the carry flag. The AMD processors do
quite well on bit instructions.
mov eax, A
mov ebx, B
mov ecx, C
mov edi, pResult ; pointer to three DWORDs
bt eax, 31
adc edx, edx
bt ebx, 31
adc edx, edx
bt ecx, 31
adc edx, edx
bt eax, 30
adc edx, edx
bt ebx, 30
adc edx, edx
bt ecx, 30
adc edx, edx
....{repeat a few times}
bt eax, 21
adc edx, edx
bt ebx, 21
adc edx, edx
mov [edi][4*2], esi
bt ecx, 21
adc edx, edx
dec edx
....{repeat a few times}
bt eax, 10
adc edx, edx
mov [edi][4*1], edx
bt ebx, 10
adc edx, edx
bt ecx, 10
adc edx, edx
dec edx
....{repeat a few times}
bt eax, 1
adc edx, edx
bt ebx, 1
adc edx, edx
bt ecx, 1
adc edx, edx
bt eax, 0
adc edx, edx
bt ebx, 0
adc edx, edx
bt ecx, 0
adc edx, edx
mov [edi][4*0], edx
bitRAKE
|