Bit field differences
utzoo!decvax!harpo!seismo!rlgvax!guy
utzoo!decvax!harpo!seismo!rlgvax!guy
Sat Apr 9 00:08:12 AEST 1983
Well, it's probably actually a function of how you number your bytes. On
the PDP-11, the low-order byte of a word has the even address and the
high-order byte has the next odd address, i.e.:
+--------+--------+
| n + 1 | n |
+--------+--------+
For hysterical raisins (namely, the way the FP-11 handles 32-bit integers),
the high- and low-order *words* of a *longword* are not handled this way
on PDP-11 C, although they ARE handled that way on all of DEC's PDP-11
software. The VAX-11 handles bytes this way (and handles words in a longword
this way, i.e. differently from PDP-11 C). The bits of a byte/word/longword/
quadword are also numbered this way. As such, they probably decided to
assign bit-fields from the low-order bit to the high-order bit.
The 68000 handles bytes and words differently (although, for no conceivable
reason, it still numbers bits from the low-order bit up), so they probably
decided to do bit fields from the high-order bit to the low-order bit.
Since you can't transmit raw binary data from the PDP-11 or the VAX-11 to
the 68000 because of the byte-order problem, it's not clear that doing the
bit fields in the PDP-11/VAX-11 fashion would really help.
The moral of the story is: if you want to exchange data between systems, put
it either in ASCII or in a binary form which is insensitive to bit order.
The "tar" tape format, the new "cpio" tape format, and the Berkeley archive
format do the former, while the System V archive format and the USG UNIX
"pack" Huffman-coded file format do the latter.
Guy Harris
RLG Corporation
{seismo,mcnc,we13}!rlgvax!guy
More information about the Comp.lang.c
mailing list