Other special cases of the bit-shift operations are nibble or byte swapping, SDCC recognizes the following expressions:
unsigned char i;and generates a swap instruction for the nibble swapping or move instructions for the byte swapping. The ”j” example can be used to convert from little to big-endian or vice versa. If you want to change the endianness of a signed integer you have to cast to (unsigned int) first.
unsigned int j;
...
i = ((i « 4) | (i » 4));
j = ((j « 8) | (j » 8));
Note that SDCC stores numbers in little-endian8.1 format (i.e. lowest order first) for most backends. However, the hc08, s08 and stm8 backends are big-endian.