The order in which the data--the bits and bytes--are arranged differs between VAX computers on the one hand, and SPARC computers on the other.
The bytes in a 32-bit integer, when read from address n, end up in the register as shown in the following tables.
Table C-8 Bits and Bytes for Intel and VAX Computers
Byte n+3 |
Byte n+2 |
Byte n+1 |
Byte n |
---|---|---|---|
31 30 29 28 27 26 25 24 | 23 22 21 20 19 18 17 16 | 15 14 13 12 11 10 09 08 | 07 06 05 04 03 02 01 00 |
Most Significant | Least significant |
Table C-9 Bits and Bytes for 680x0 and SPARC Computers
Byte n |
Byte n+1 |
Byte n+2 |
Byte n+3 |
---|---|---|---|
31 30 29 28 27 26 25 24 | 23 22 21 20 19 18 17 16 | 15 14 13 12 11 10 09 08 | 07 06 05 04 03 02 01 00 |
Most Significant | Least significant |
The bits are numbered the same on these systems, even though the bytes are numbered differently.
Following are some possible problem areas:
Passing binary data over the network. Use External Data Representation (XDR) format or another standard network format to avoid problems.
Porting raster graphics images between architectures. If your program uses graphics images in binary form, and they have byte ordering that is not the same as for images produced by SPARC system routines, you must convert them.
If you convert character-to-integer or integer-to-character between architectures, you should use XDR.
If you read binary data created on an architecture with a different byte order, then you must filter it to correct the byte order.
See also the man page, xdr(3N).