[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Castle Adventure by David Malmberg
In article <20040715182057.11545.00001407@mb-m11.aol.com>,
Michael J. Mahon <mjmahon@aol.com> wrote:
> Despite the "religious wars" around endianness, no computer
> subculture I am familiar with has been so rabidly little endian
> that they put the LSB at the _left_ end of a byte.
A byte has no "left" or "right" end really -- only when you print out
the contents of the byte on screen or paper there will be a left and
right end. And indeed our culture is very biased towards writing the
most significat digit at the left and the least significant digit at
the right.
So the issue of endianness is not really about writing the LSB or the
MSB at the left, but about whether to assign the LSB or the MSB the
lowest address. And that's why the order of bits within a byte is a
non-issue in most cases: on almost all computer architectures, bits
aren't individually addressed. If you want to access a specific bit,
or some bits, of a byte, you must read the entire byte, and then
shift and mask to get at the bit(s) you're interested in.
The situation is the same concerning bytes in a word-addressed
machine, such as the good ol' CDC 6600: it had 60-bit word length and
word addressing, which means you must access at least 60 bits (one
word) when accessing computer memory. A specific memory address
referred to one whole 60-bit word; the next address referred to the
next 60-bit word, and so on. One word was divided into 10 bytes of 6
bits each (==> 64 possible characters: uppercase only, no control
characters) - but that was only a software convention without any
hardware support. To access a specific byte, the whole word
containing that byte had to be read and then one had to shift and
mask to access that byte. And to delete one character in a
multi-character string spanning seveal bytes was a quite complex and
time consuming operation, so the CDC 6600 was not suitable for text
processing.... Anyway, the issue of "little endian" vs "big endian"
byte order on the CDC 6600 was a non-issue since bytes were not
individually addressable on that machine.
However, even of today's computers are byte addressable and not
bit addressable, there are some bit manipulation instructions
for e.g. setting, clearing, and testing a specific bit within
a byte or a word. The bit is identified with a digit, and
the bit count starts at 0 or 1 depending on convention. And
the count *always* starts at the LSB; I know of no case where
the MSB is identified with a 0 or 1 in these instructions.
So in that respect, the bit order within a byte is *always*
"little endian" -- and there's no controversy about that.
> And when a word-oriented big endian actually does multiple-precision
> arithmetic, they usually arrange the words in little endian order. ;-)
I have the opposite experience. In e.g. ASN.1 ("Abstract Syndax
Notation", a standard commonly used to store RSA keys and stuff like
that) and its implementation specifications BER and DER ("Basic
Encoding Rules, "Distingushed Encoding Rules") it's explicitly
specified that multi-byte binary values shall be stored in big-endian
form. And if the value is a signed integer, it shall be stored in
two-complement form as well. Check out
http://www.columbia.edu/~ariel/ssleay/layman.html
for more info about ASN.1, BER and DER
--
----------------------------------------------------------------
Paul Schlyter, Grev Turegatan 40, SE-114 38 Stockholm, SWEDEN
e-mail: pausch at stockholm dot bostream dot se
WWW: http://www.stjarnhimlen.se/
http://home.tiscali.se/pausch/