]> git.defcon.no Git - hm-trp-tool/blob - swap.c_example
Adding QT4-based GUI tool. More-or-less useable
[hm-trp-tool] / swap.c_example
1 #include <bits/byteswap.h> /* __bwap_{16,32} */
2
3 /*
4 Basically, does:
5 uint32_t swap_uint32 ( uint32_t num )
6 {
7 return ( (num>>24) & 0x000000ff) | // move byte 3 to byte 0
8 ( (num<<8) & 0x00ff0000) | // move byte 1 to byte 2
9 ( (num>>8) & 0x0000ff00) | // move byte 2 to byte 1
10 ( (num<<24) & 0xff000000); // byte 0 to byte 3
11 }
12
13 uint16_t swap_uint16 ( uint16_t num )
14 {
15 // Move UP and mask | Move DOWN and mask
16 return( (num<<8) & 0xff00 ) | ( (num>>8) & 0x00ff );
17 }
18 */
19