Macro implementation Size-end conversion
/* define multiline macros after each line with a ' \ '/
#define SW16 (x) \ (short) ((short)
(x) & (short) 0x00ffu) << 8 | \< c5/> ((short) (x) & (short) 0xff00u) >> 8))
Suppose X=0xaabb
(short) (x) & (short) 0x00ffu) and 16-digit high 8-bit 0 0X00BB
Then <<8 to the left 8-bit lower 8-bit into a high 8-bit low 8-bit 0 results for 0XBB00
((short) (x) & (short) 0xff00u) >> 8)) The exact opposite result is 0X00AA
Two results again or one 0xbb00 | The 0X00AA is 0xbbaa.
macro implements size and spin network byte order
typedef unsigned short int uint16;
typedef unsigned long int uint32;
#define BIGLITTLESWAP16 (a) (((UInt16) (a) & 0xff00) >> 8) | ((
uint16) (a) & 0X00FF) << 8) c4/> #define BIGLITTLESWAP32 (a) ((UInt32) (a) & 0xff000000) >>) |
((UINT32) (a) & 0x00ff0000 ) >> 8) | \ ((
UInt32) (a) & 0x0000ff00) << 8 | ((
uint32) (a) & 0x000000ff) << 24)