Hi all, I am trying to understand the difference between big and little endianess of the data storage format. Which one is good ? Any specific advantage ? Thanks.
So if there is no specific advantage Some like apples and some like oranges. for those that like apples best, apples have an advantage over oranges. Eik
Chip design guys tend to like little-endian. Consider that the addresses don't change just because the width of the data type changes. U32 large; U8 small = large; On a big-endian system, this requires the processor to internally add 3 to &large to fetch the right byte. On a little endian system, it "just works". small = *(((U8*)&large) + sizeof(large) - 1); // big endian small = *(U8*)&large; // little endian This is a small example, but there are lots of little internal design issues that make the chip designers happier with little endian. Their circuits don't really have any particular width (21 bits, or 73, is just as easy for them to declare as 32), and little-endian keeps the various widths better aligned internally. You also know where the LSB is, which is more important when connecting internal logic interfaces that it may seem at the software level. Big endian is considered by some to be more human-readable. IMO, that's just conditioning from the big-endian format used with Arabic numerals. One real, practical advantage of big-endian format is that most common communications protocols use big-endian as their network byte order. Both Ethernet and IP, for example, are big-endian. So, if you write comms code on a little-endian processor, you continually have to reverse length fields, checksums, and so on. Several recent processor designs, including PPC and ARM, can be configured for either format. 8051s really don't care, since they're an 8-bit processor. Keil C51 happens to use the big-endian format (mostly; generic pointers are an exception).
Hi davis, Thanks for educating me about the endianness. This is useful information for me. Thanks again.