Prev: Fair scheduling of the equal priority tasks in RTOS
Next: Interleaved Read/Write to Compact Flash Card
From: justincao on 16 Apr 2010 11:57 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! --------------------------------------- Posted through http://www.EmbeddedRelated.com
From: d_s_klein on 16 Apr 2010 12:59 On Apr 16, 8:57 am, "justincao" <futuremaster(a)n_o_s_p_a_m.126.com> wrote: > 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 definition please? Thanks! > > --------------------------------------- > Posted throughhttp://www.EmbeddedRelated.com Hi. The "bit_spread operation" is a user defined function. You included the definition of this function in your post. RK
From: Tim Wescott on 16 Apr 2010 13:26 justincao wrote: > Hi, > > I'm reading Andrew N. Sloss's book > <<ARM System Developers Guide-Designing and Optimizing System Software>>. > >> exact copy of posting to comp.dsp snipped << You should also ask "What is multiple posting?". Go to Wikipedia, and read their excellent article on cross posting. Then follow this link that they give: http://www.blakjak.demon.co.uk/mul_crss.htm Then, if you must, go ahead and cross post. But please don't multiple-post! -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
From: Thad Smith on 17 Apr 2010 19:58
justincao wrote: > he used PERMUTE_B macro to achieve bit_spread operation. But what is bit > spread? Can anybody give me a defintion please? Thanks! By bit spread, I think he means having a single input bit affect several output bits. I have seen it used for error detection, such as CRC; hashing, to reduce collisions; and encryption, to make cryptanalysis harder. -- Thad |