pauls@sri-unix (10/23/82)
The following is part of a news item that refers to the
Motorola method of ordering bytes as being inherently
correct, from a "purist's perspective".
............................................................
>From teklabs!edr Thu Oct 21 07:51:07 1982
Subject: NS16000
Newsgroups: net.micro
B) Somebody screwed up and numbered the bytes backwards
again. In the canonical sense, IBM and Motorola order their
bytes correctly. This is one of the few cases where IBM
truely did things right and we didn't learn the lesson. DEC
and Intel, however, have their bytes nuxi-ed from the canon-
ical form. National has put themselves into the nuxi world.
This makes it easier to port software from the VAX, etc.,
but from a purist's perspective, it merely perpetuates an
error.
Ed Reuss
teklabs!edr
............................................................
What constitutes pure byte order? Consider an unsigned
binary integer of arbitrary precision, independent of any
machine and dependent only on the method by which we write
them. One digit is always significant, the least signifi-
cant bit. Being computer hackers and digital dudes, we
start counting at zero rather than one. As we increment the
number we add significant digits to the left, numbering
their position as we go.
<== ... ... 33 32 31 30 ... ... 3 2 1 0.
If we were to assign a bit address to our number the LSB
would be the obvious choice. The address of the MSB varies
with the magnitude of the number.
Now we build machines to deal with binary numbers. For
our convenience we impose a higher-level structure on binary
numbers. We organize them into groups of eight called
bytes. Terms such as "most significant byte" and "least
significant byte" are meaningful. Following the machine-
independent pattern established in ordering bits in binary
numbers (,as well as digits in decimal numbers,) our arbi-
trary precision binary number looks like this:
<== byte 32 | byte 24 | byte 16 | byte 8 | byte 0 |
Each byte is identified by the address of the least signifi-
cant bit that it contains.
At this point we begin to take our artificial organiza-
tion seriously. We ignore bits, calling bytes the basic
unit of memory organization. The name of the byte is the
name of the LSB divided by the number of bits per byte.
<== byte 4 | byte 3 | byte 2 | byte 1 | byte 0 |
The next data type is the word. Two adjacent bytes
form one word. The address or name of the word is the
lowest byte address contained within it.
<== word 4 | word 2 | word 0 |
The long word is four bytes or two words long. The
address of a long word is the lowest byte address contained
within it.
<== long word 4 | long word 0 |
All of the processors being considered in this discussion
use byte addresses to point to words and long words. They
all use the lowest byte address contained within a word as
the address of the word. Now let us look at the organiza-
tion of a long word in the address space of each processor.
Address MC68000 Z8000 NS16000, VAX
0103 1 0 3
0102 0 1 2
0101 3 2 1
0100 2 3 0
The MC68000 scheme for clarifying the lack of
correspondence between addresses and byte significance is to
designate byte zero to be bits 8 to 15 of a data word, and
byte one to be bits 0 to 7. This makes their word organiza-
tion look like that of the Z8000 but breaks the only "pure"
machine independent rules we can devise;
A. Uniform monotonicity. (Higher = bigger = more signifi-
cant)
B. Identify a datum by its least significant sub-datum.
The Z8000 is almost right. The change of byte address
within a long word is monotonic, but while the address is
increasing the byte significance decreases. Still it is
quite natural to use because we like to read numbers start-
ing with the most significant byte.
For the VAX and the 16000 bytes, words, and long words
can be viewed as a grouping convention superimposed upon
arbitrary precision binary numbers. A higher address always
points to a more significant quantity, be it bit, byte,
word, long word, etc. A binary number of any size can be
shifted left, and the carry of any data type is guaranteed
to shift into the data structure at the next higher address.
Restricting word alignment to even byte boundaries is con-
ceptually unnecessary, and the results of misalignment are
unambiguous. In fact, although the hardware implications
are expensive, this data organization is compatible with
arbitrary bit alignment of arbitrary precision binary words.
All that is missing is the use of bit rather than byte
addresses.
Paul Sweazey
(teklabs!tekmdp!pauls)
steveg@sri-unix (10/24/82)
Please, let's not dredge up the issue of byte ordering. I consider it adequately covered in Danny Cohen's paper "On Holy Wars and a Plea for Peace". It was published a while back in IEEE Computer magazine, but was handed around the arpanet community for quite some time before that. The gist of his argument is that it doesn't really matter what order you use as long as it's consistent. Steve Glaser, teklabs!steveg
terryl@sri-unix (10/25/82)
Sorry Paul, but I have to disagree with you on the byte ordering of the 68000. I quote from my MC68000 16-Bit Microprocessor handbook from Motorola, section 2.4: Data Organization In Memory "Bytes are individually addressable with the high order byte having the same address of as the word shown in figure 2-1. The low order byte has an odd address that is one count higher than the word address. Instructions and multibyte data are accessed only on word(even byte) boundaries. If a long word datum is located at address n(n even), then the second word of that datum is located at address n+2." And the manual goes on to show pictures of byte, word, and long data types, which unfortunately I can't show here, mainly because of my laziness in typing it in, so the 68000 has exactly the same byte layout as the Z8000, assuming what you said about the Z8000 is correct. How you got the byte ordering that you did is a mystery to me. Terry Laskodi of Tektronix
tjt (11/06/82)
Sorry, the MC68000 does use a consistent byte order: the most significant byte of a word or longword has the lowest byte address, and the least significant byte has the highest byte address. Also, the most significant 16-bits of a 32-bit longword are at a lower address than the least significant 16-bits. Thus, the MC68000 byte ordering is identical to th ordering in the Z8000 and the IBM 360.