What is the best way to manipulate bits in a byte?
I got to a situation where I need to organize the bit's order of a byte in a big loop (I mean it), so I say "best" in every aspect, including performance.
The less convertion instructions and more cpu native ones, the better.
Let me be more specific:
I have a shift Integer() array that contains an order. Also, a buffer() byte array.
For example:
Dim shift as Integer() {2,1,0,7,5,4,6, 3}
dim buffer as Byte() 'variable with data
in the case above and with a byte like 10010111, the byte should be transformed into 00110011.
take a look:
------------------------
From: 10010111
To : 00110011
------------------------
following the shift "index" order.
This seems a simple problem but the performance here is really critical. It would be great if we could do this only with Xor sort of instructions (since its low level)
Any suggestions?
I got to a situation where I need to organize the bit's order of a byte in a big loop (I mean it), so I say "best" in every aspect, including performance.
The less convertion instructions and more cpu native ones, the better.
Let me be more specific:
I have a shift Integer() array that contains an order. Also, a buffer() byte array.
For example:
Dim shift as Integer() {2,1,0,7,5,4,6, 3}
dim buffer as Byte() 'variable with data
in the case above and with a byte like 10010111, the byte should be transformed into 00110011.
take a look:
------------------------
From: 10010111
To : 00110011
------------------------
following the shift "index" order.
This seems a simple problem but the performance here is really critical. It would be great if we could do this only with Xor sort of instructions (since its low level)
Any suggestions?
Comment