Do the shuffle...
Posted: Mon Nov 22, 2021 11:55 am
I have a question relating to bit reordering in a byte / word or even long word.
I have seen algorithms to swap one value for another by using XOR technique, and also algorithms to swap bits in the byte or word from lowest to highest and vice versa (reversing the bit pattern).
What I want to achieve is the ability to reorder the bits in a byte or word (and possibly long word) so that each bit can have a new defined location (as expressed by the user) but each bit maps uniquely to a new or the same location in the byte - with no double assignments.
To give you some background - I am interested in providing something similar to the QEP III's address and data bit reordering.
I was just curious to know if there was any technique that might make this more optimized - as at the moment I can only envisage running through a loop to process each bit in the byte or word and use shifts / rotates to move the bits up or down as required, whilst maintaining the previous movements made so far - it seems kludgy at best...
I have seen algorithms to swap one value for another by using XOR technique, and also algorithms to swap bits in the byte or word from lowest to highest and vice versa (reversing the bit pattern).
What I want to achieve is the ability to reorder the bits in a byte or word (and possibly long word) so that each bit can have a new defined location (as expressed by the user) but each bit maps uniquely to a new or the same location in the byte - with no double assignments.
To give you some background - I am interested in providing something similar to the QEP III's address and data bit reordering.
I was just curious to know if there was any technique that might make this more optimized - as at the moment I can only envisage running through a loop to process each bit in the byte or word and use shifts / rotates to move the bits up or down as required, whilst maintaining the previous movements made so far - it seems kludgy at best...