EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Big-Endian vs. Little-Endian

Started by Everett M. Greene August 20, 2004
On Mon, 23 Aug 2004 09:12:00 +0200, "David Brown"
<david@no.westcontrol.spam.com> wrote:

[...]
>It depends on what you are used to. I use both big-endian (68k, ppc) and >little-endian (msp430, avr (little-endian by compiler convention more than >architectural necessity, since it is 8-bit), Nios) processors. I find
More than a compiler convention. Consider adiw, sbiw, [f]mul[s[u]], and spm. The X, Y, and Z registers are also defined with the higher-numbered register as the MSB. However, the [r]call instruction pushes the lsb of the pc onto the stack first, resulting in a big-endian layout in memory. The 8051 is similarly of two minds here: the call instruction contains a little-endian destination address, but pushes the return address in big-endian order (or vice-versa -- it's been a while...)
>little-endian to be easier to work with, easier to view in hex dumps, and >easier to work out which bit is in which place - even though I know that >big-endian is more consistent and should be easier. It's just a matter of >habit and familiarity.
Indeed. It's like clasping your hands together in a double fist. Do you interlock your fingers so your left thumb is over the right, or the right is over the left? When you switch, it feels like you're holding someone else's hand. There are two ways to do it. Neither is "better" than the other. One way feels comfortable, the other doesn't. But some do it one way, and some the other. And you're reluctant to switch just because someone else says it's the "right" way. Regards, -=Dave -- Change is inevitable, progress is not.
On Tue, 24 Aug 2004 05:10:25 GMT, Bryan Hackney
<bh.remove@bhconsult.com> wrote:

>Rene Tschaggelar wrote: >> Bryan Hackney wrote: >>
[...]
>>> I say natural order - maybe that should be anthropic order. We read >>> numbers LtoR, MSD to LSD. >>> >> >> Do you have troubles reading a UART stream from a scope then ? >> A minimum of flexibility is expectable from people working >> embedded... >> >> Rene > >Can you say "non sequitur"?
Latin for "it does not follow." Except it does. If you look at the serial stream from a UART on a scope, the bits appear left to right, LSb to MSb. And depending on where you hook into the circuit, ones may be low and zeros high. Does take some getting used to. OTOH, if the serial stream is an ASCII text string, it DOES tend to be transmitted leftmost character first... Regards, -=Dave -- Change is inevitable, progress is not.
On 2004-08-24, Stephen Pelc <stephenXXX@INVALID.mpeltd.demon.co.uk> wrote:

>>I say natural order - maybe that should be anthropic order. We >>read numbers LtoR, MSD to LSD.
> These numbers are from Arabic which is a right to left language. :-)
And the latin-alphabet-using people who orignally borrowed arabic numerical notation for some reason neglected to flip them around to match the direction of the rest of the language. -- Grant Edwards grante Yow! I'm not an at Iranian!! I voted for visi.com Dianne Feinstein!!
On Mon, 23 Aug 2004 15:18:03 GMT, Bryan Hackney
<bh.remove@bhconsult.com> wrote:

>I say natural order - maybe that should be anthropic order. We read >numbers LtoR, MSD to LSD.
Be careful about arguments based on "naturalness". When Arabic numerals made their way into Western left-to-right writing, the original LSD to MSD ordering was reversed. In Arabic, which reads right-to-left, the ones digit is on the right. Apparently the Indian system from which the Arabic numerals came also had the LSD first, or little-endian. -- Jim McGinnis
On 2004-08-24, Jim McGinnis <remove_this.mcginnis@and_this.ieee.org> wrote:
> On Mon, 23 Aug 2004 15:18:03 GMT, Bryan Hackney ><bh.remove@bhconsult.com> wrote: > >>I say natural order - maybe that should be anthropic order. We read >>numbers LtoR, MSD to LSD. > > Be careful about arguments based on "naturalness". When Arabic > numerals made their way into Western left-to-right writing, > the original LSD to MSD ordering was reversed. In Arabic, > which reads right-to-left, the ones digit is on the right. > Apparently the Indian system from which the Arabic numerals > came also had the LSD first, or little-endian.
And in western languages (English as well) numbers were read little-endian (from "right to left" -- LSD first) until recently. "Four and twenty blackbirds..." -- Grant Edwards grante Yow! I am having a at pleasant time!! visi.com
Grant Edwards wrote:
...
> And in western languages (English as well) numbers were read > little-endian (from "right to left" -- LSD first) until > recently. > > "Four and twenty blackbirds..." >
That's a British rhyme. American is different: "Four score and seven years ago, our fathers brought forth ..."
This is drifting wildly OT, of course, but what the heck.

Grant Edwards <grante@visi.com> wrote:

> And in western languages (English as well) numbers were read > little-endian (from "right to left" -- LSD first) until > recently.
What do you mean, "until recently"? English still does it that way from 13 to 19. In German (and most related languages, AFAIK) that's how it is done all the way up to 99, and is quite unlikely to change, ever. And just to make it more confusing, it's done that way only for tens and ones, i.e. 524 is "fuenfhundertvierundzwanzig", i.e. "five hundred four and twenty". And let's not even get started about French, where what they say when they mean 97 translates, literally, as "four twenty ten seven". Now you try and install some sense in terms of endianness into *that* ;-) Back to the topic: yes, endianness is, and always was, an almost entirely arbitrary choice. Which makes the term so well-chosen. [The literary reference from Gulliver's Travels is about endless war being waged between two groups of people, over which end of an egg you should start at opening it: the big or the little end. With both the eggs and the bits, there are essentially no rational arguments towards either side, but you still have to make a choice, and the world might be a better place if everybody could agree on making that choice the same way, once and for all.] That sait, there was one real argument in favour of one side. It favoured little-endian, and has long since been obliterated by CPU engineering. It applied in situations where three conditions held: 1) memory is narrower than arithmetic registers 2) key ALU building blocks (adders, shifters, the likes) are narrower than CPU registers, so operations take several cycles through them, passing around carry bits. 3) memory can be read "forward" faster than "backward" In this situation, doing little-endian allows to intermix ALU cycles and memory fetches, and can thus be noticeably faster than big-endian. The difference will be governed by the speed penalty for stepping through address space in the "wrong" direction. -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.
On 2004-08-24, Rick Merrill <RickMerrill@comTHROW.net> wrote:
> Grant Edwards wrote: > ... >> And in western languages (English as well) numbers were read >> little-endian (from "right to left" -- LSD first) until >> recently. >> >> "Four and twenty blackbirds..." >> > > That's a British rhyme. American is different:
That's why I said "until recently." 200 years is pretty recent in the development of languages.
> "Four score and seven years ago, our fathers brought forth ..."
-- Grant Edwards grante Yow! Hello... IRON at CURTAIN? Send over a visi.com SAUSAGE PIZZA! World War III? No thanks!
Grant Edwards wrote:

> On 2004-08-24, Jim McGinnis <remove_this.mcginnis@and_this.ieee.org> wrote: > >>On Mon, 23 Aug 2004 15:18:03 GMT, Bryan Hackney >><bh.remove@bhconsult.com> wrote: >> >> >>>I say natural order - maybe that should be anthropic order. We read >>>numbers LtoR, MSD to LSD. >> >>Be careful about arguments based on "naturalness". When Arabic >>numerals made their way into Western left-to-right writing, >>the original LSD to MSD ordering was reversed. In Arabic, >>which reads right-to-left, the ones digit is on the right. >>Apparently the Indian system from which the Arabic numerals >>came also had the LSD first, or little-endian. > > > And in western languages (English as well) numbers were read > little-endian (from "right to left" -- LSD first) until > recently. > > "Four and twenty blackbirds..."
This is interesting. Our language (not english) still has it this way. Any hints on when and on what occasion that was changed. Rene
On 2004-08-24, Hans-Bernhard Broeker <broeker@physik.rwth-aachen.de> wrote:

>> And in western languages (English as well) numbers were read >> little-endian (from "right to left" -- LSD first) until >> recently. > > What do you mean, "until recently"?
Sometime between 0 and 200 years ago? :) [More recent for some languages than others.]
> That sait, there was one real argument in favour of one side. It > favoured little-endian, and has long since been obliterated by CPU > engineering. It applied in situations where three conditions held: > > 1) memory is narrower than arithmetic registers > 2) key ALU building blocks (adders, shifters, the likes) are > narrower than CPU registers, so operations take several cycles > through them, passing around carry bits. > 3) memory can be read "forward" faster than "backward"
Point 3) is definitely true for drums, tapes and cards! -- Grant Edwards grante Yow! Where's SANDY DUNCAN? at visi.com

Memfault Beyond the Launch