Big-Endian vs. Little-Endian

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 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.

Reply to
David Brown
Loading thread data ...

You've missed the point that some processors can be used in either big or little endian mode.

--
Paul Black                        mailto:paul.black@oxsemi.com
Oxford Semiconductor Ltd          http://www.oxsemi.com
 Click to see the full signature
Reply to
Paul Black

This information would be immediately available on some little endian systems as well: the ARM instruction set, for example, can encode an immediate offset in the instruction.

--
Paul Black                        mailto:paul.black@oxsemi.com
Oxford Semiconductor Ltd          http://www.oxsemi.com
 Click to see the full signature
Reply to
Paul Black

Yes, but many of these have a prefererance for one mode. The PPC architecture, for example, perfers big-endian - some implementations (like the MPC56x) don't support little-endian at all, while those that do have certain restrictions - I believe the string instructions only function in big-endian mode, for example. This is because all cpus have are fixed-endian at heart (normally big- or little-endian, though there have historically been computers with all sorts of arrangements), and the non-native mode is handled using thunking - the bytes of multi-byte data are re-arranged on the fly as data is moved into and out of the cpu.

Reply to
David Brown

The one I'm most familar with is the ARM where the endianness is set by an external line.

CPUs internally have no endianness. The endianness only comes into play when accessing memory.

--
Paul Black                        mailto:paul.black@oxsemi.com
Oxford Semiconductor Ltd          http://www.oxsemi.com
 Click to see the full signature
Reply to
Paul Black

When dealing with bitstreams such as raster lines, big-endian is way better. The ultimate machine for these apps have large words and are big-endian.

Bulk operations such as applying masks are not affected, but some operations such as shifting, shearing, and bit-bending are way easier on a natural order machine when having to cast around types.

I say natural order - maybe that should be anthropic order. We read numbers LtoR, MSD to LSD.

--
------------------------------------------------------------
Creepy, Soulless Gigolo for President ? NOT !
 Click to see the full signature
Reply to
Bryan Hackney

Now that you're talking about the question I raised, which choice do people make when they have a free choice?

Reply to
Everett M. Greene

Do you have troubles reading a UART stream from a scope then ? A minimum of flexibility is expectable from people working embedded...

Rene

--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com
& commercial newsgroups - http://www.talkto.net
Reply to
Rene Tschaggelar

The issue is so low down in the priority list that I can't imagine a situation where the endianness of the processor would make the difference, unless there was something in the application itself that made one choice or the other preferable for compatibility with other components of the system.

-Robert Scott Ypsilanti, Michigan (Reply through this forum, not by direct e-mail to me, as automatic reply address is fake.)

Reply to
Robert Scott

Can you say "non sequitur"?

--
------------------------------------------------------------
Creepy, Soulless Gigolo for President ? NOT !
 Click to see the full signature
Reply to
Bryan Hackney

Do processors with high end at the lower address tend to have a more regular instruction set than the reverse persuasion? I'm thinking of the Motorola mindset (6800, 6803, 6809 of blessed memory, 68000) v the nightmares of 8085/Z80/80x86. In the days when I used to write a lot of assembler, I know which ones I preferred!

Paul Burke

Reply to
Paul Burke

The only application we've found where endianness might matter is for a comms stack where the protocol defines data to be in a particular (usually big-endian) format. In practice, this has very little impact on performance. For example, in a TCP/IP stack, checksum generation is far more important than the impact of endianness.

Stephen

-- Stephen Pelc, snipped-for-privacy@INVALID.mpeltd.demon.co.uk MicroProcessor Engineering Ltd - More Real, Less Time

133 Hill Lane, Southampton SO15 5AF, England tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691 web:
formatting link
- free VFX Forth downloads
Reply to
Stephen Pelc

These numbers are from Arabic which is a right to left language. :-)

Stephen

-- Stephen Pelc, snipped-for-privacy@INVALID.mpeltd.demon.co.uk MicroProcessor Engineering Ltd - More Real, Less Time

133 Hill Lane, Southampton SO15 5AF, England tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691 web:
formatting link
- free VFX Forth downloads
Reply to
Stephen Pelc

And then there is the USB, which is little-endian. IIRC, at least one of the descriptors has unaligned members as well.

--
Michael N. Moran           (h) 770 516 7918
5009 Old Field Ct.         (c) 678 521 5460
 Click to see the full signature
Reply to
Michael N. Moran

The one that matches the byte-order of I/O devices, for example.

--
Wil
Reply to
Wil Taphoorn
[...]

The VAX was _very_ regular (too regular for its own good), and was little-endian.

The AVR is little-endian.

Regards,

-=Dave

--
Change is inevitable, progress is not.
Reply to
Dave Hansen
[...]

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...)

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.
Reply to
Dave Hansen

[...]

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.
Reply to
Dave Hansen

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
 Click to see the full signature
Reply to
Grant Edwards

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
Reply to
Jim McGinnis

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.