Little-endian PowerPC
Little-endian PowerPC
Posted Oct 7, 2010 14:21 UTC (Thu) by etienne (guest, #25256)In reply to: Little-endian PowerPC by jengelh
Parent article: Little-endian PowerPC
Last time I looked gcc was not able to generate (did not know about) the bswap instruction.
I do not think gcc knows about "load/store word with byte reversed" of PPC neither.
For BE CPU, you still need some assembly instuctions to cast the value 3 in a 16 bits word to the value 3 in a byte, and pass its address... at least in gcc you need an explicit temporary.
It is easy to assume (source of a lot of bugs) that when an constant integer contains the value 15 you can cast the address of that integer to a char or short pointer; to get rid of those bugs it seems people prefer little endian.
But basically your byte endianess is directly depending on the endianess of all the environment, not only the network interface.
The "best" I worked with was a big endian main processor connected to a little endian coprocessor connected to a big endian FPGA: at the time you know that the message in the coprocessor contains a 32 bits value and you should byte-swap it, you should byte-swap it back to write it to the FPGA... Basically do not byte-swap it at all but for display/debug.
I do not think gcc knows about "load/store word with byte reversed" of PPC neither.
For BE CPU, you still need some assembly instuctions to cast the value 3 in a 16 bits word to the value 3 in a byte, and pass its address... at least in gcc you need an explicit temporary.
It is easy to assume (source of a lot of bugs) that when an constant integer contains the value 15 you can cast the address of that integer to a char or short pointer; to get rid of those bugs it seems people prefer little endian.
But basically your byte endianess is directly depending on the endianess of all the environment, not only the network interface.
The "best" I worked with was a big endian main processor connected to a little endian coprocessor connected to a big endian FPGA: at the time you know that the message in the coprocessor contains a 32 bits value and you should byte-swap it, you should byte-swap it back to write it to the FPGA... Basically do not byte-swap it at all but for display/debug.
