Byte order (retitled)

Richard Harter g-rh at cca.UUCP
Mon Apr 7 11:32:34 AEST 1986


In article <> rbj%icst-cmr at smoke.UUCP writes:
>Bill Crews writes:
>
>	The only reason you got -28672 for BIG instead of nulls is
>	because your machine has backwards byte order.
>
>Sorry Bill, *you're* the one that's got backwards byte order. Little
>Endian is `correct', even tho bucking historical convention.
>
>My reasoning is this: The original byte ordering was done the obvious
>way, Big Endian. If this was so perfect, why would a sane man design
>anything Little Endian? For compelling mathematical reasons!
>You wouldn't number your bits backwards (within a register) would you?
>Admittedly, some people do, but they must not know any better.
>
	Well, no, little-endian came about because the engineers at DEC
who designed the PDP-11 made an arbitrary decision that was not well
thought out.  I will not essay to defend the sanity of DEC engineers,
and cannot recommend that any one else do so (:-)).  It was a bad
decision.

	Consider the following problem.  You have an array of 4 byte
integers.  If you sort the array numerically you get one result.  If
you regard the bytes as characters and sort them lexicographically on
a little endian machine you get a different result.  The reason is that
the most signifigant byte occupies the eight least signifigant bits.
Consistency of signifigance requires that the direction of signifigance
be the same for both bytes and bits.

	Little-endian came about from the idea of making the lsb of a
word be bit 0.  From this it follows that byte 0 should be the lsbyte
of the word.  This is in natural analogy with the idea that word 0
is the l.s. word.  The object is:

bit 0 is the lowest address bit
byte 0 is the lowest address byte
word 0 is the lowest address word

This is the "all addressing flows in the same direction" constraint.
If that were the only constraint either big-endian or little-endian
would be acceptable, provided that it were followed through consistently.
However we have a second constraint, that comparison be valid whether
a word is considered as a character string or as a number.  Given
both constraints, the correct addressing assignment is:

bit 0 is the most signifigant bit
byte 0 is the most signifigant byte.

In short, little-endian was a mistake, is a mistake, and will continue
to be a mistake.

		Richard Harter, SMDS Inc.



More information about the Comp.lang.c mailing list