Lookup Table Bit-Reversed Sorting
; A3 256-word array, B5 256-byte bit-rev index lut MVK .S1 255,A2 ; index to swap 0 … 255|| MVK .S2 255,B2 ; 255 bit reversed is 255
|| ZERO .L1 A1 ; don’t swap first index
|| MV .L2 A3,B3 ; B3 also points to data
SUB .S1 A2,1,B1 ; B1=A2-1
sort .trip 255 ; tell assembler loop 255X [A2] LDBU .D2 *B5[B1],B7 ; B7=next bit-rev index [A2] SUB .S1 A2,1,A2 ; decrement loop counter
||[B1] SUB .S2 B1,1,B1 ; B1=A2-1
||[A1] MV .L1 B2,A4 ; A4=B2 for swapping||[A1] MV .L2 A2,B4 ; B4=A2 for swapping||[A1] LDW .D1 *A3[A2],A6 ; A6=data at index||[A1] LDW .D2 *B3[B2],B6 ; B6=data at bit-rev index CMPGT .L1 A2,B7,A1 ; A1=switch next values
|| MV .L2 B7,B2 ; B2=bit-rev index
||[A1] STW .D1 A6,*A3[A4] ; swap data||[A1] STW .D2 B6,*B3[B4]||[A2] B .S2 sort ; if A2 != 0, then branch
Throughputof 3 cycles/coefficient