cortexelf-v1: Add bit flipping array generator
[fw/altos] / src / cortexelf-v1 / ao_flip_bits.5c
1 #!/usr/bin/nickle
2
3 int flip_bits(int a)
4 {
5         int result = 0;
6         for (int pos = 0; pos < 8; pos++)
7                 if ((a & (1 << pos)) != 0)
8                         result |= (1 << (7 - pos));
9         return result;
10 }
11
12 printf ("static uint8_t ao_flip_bits[256] = {\n");
13
14 for (int i = 0; i < 256; i++) {
15         printf (" 0x%02x,", flip_bits(i));
16         if ((i & 0xf) == 0xf)
17                 printf("\n");
18 }
19 printf("};\n");