Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bitwise transpose of 8 bytes

Tags:

c

embedded

I am looking for an efficient algorithm in C to bitwise-transpose 8 bytes of data. What I mean with this is that if I have 8 bytes like this:

00011100
00111000
00000001
00000000
11000000
00000000
11111111
01010101

I want to get the following 8 bytes:

00001010
00001011
01000010
11000011
11000010
10000011
00000010
00100011

And since I want to use this on an embedded platform, it should be as fast as possible :-)

All ideas are much appreciated!

like image 602
Arnaud Gouder de Beauregard Avatar asked Feb 11 '10 11:02

Arnaud Gouder de Beauregard


1 Answers

See Hacker's Delight, Chapter 7-3.

like image 140
Johan Kotlinski Avatar answered Nov 15 '22 04:11

Johan Kotlinski