From: justincao on
Hi,

I'm reading Andrew N. Sloss's book
<<ARM System Developers Guide-Designing and Optimizing System Software>>.

There is a description about Bit Permutation.
I extrat several lines of code here:

7.6.2.1 Bit PermutationMacros
mask0 EQU 0x55555555 ; set bit positions with b0=0
mask1 EQU 0x33333333 ; set bit positions with b1=0
mask2 EQU 0x0F0F0F0F ; set bit positions with b2=0
mask3 EQU 0x00FF00FF ; set bit positions with b3=0
mask4 EQU 0x0000FFFF ; set bit positions with b4=0

MACRO
PERMUTE_B $j, $k
; [ .. b_j .. b_k .. ] -> [ .. b_k .. b_j .. ] and j>k
LDR m, =(mask$j:AND::NOT:mask$k) ; set when b_j=0 b_k=1
EOR t, n, n, LSR#(1 << $j)-(1 << $k)
AND t, t, m ; get bits where b_j!=b_k
EOR n, n, t, LSL#(1 << $j)-(1 << $k) ; change if bj=1 bk=0
EOR n, n, t ; change when b_j=0 b_k=1
MEND

bit_spread ; n= [ b4 b3 b2 b1 b0 ]
PERMUTE_B 4,3 ; ->[b3b4b2b1b0]
PERMUTE_B 3,2 ; ->[b3b2b4b1b0]
PERMUTE_B 2,1 ; ->[b3b2b1b4b0]
PERMUTE_B 1,0 ; ->[b3b2b1b0b4]
MOV pc, lr

he used PERMUTE_B macro to achieve bit_spread operation. But what is bit
spread? Can anybody give me a defintion please? Thanks!