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-endiantypeset@protect @@footnote SF@gobble@opt Usually 8-bit processors don't care much about endianness. This is not the case for the standard 8051 which only has an instruction to increment its dptr-datapointer so little-endian is the more efficient byte order. format (i.e. lowest order first).