PATH 
ADC Home > Documentation > Hardware > Device Managers and Drivers > PCI Card Services > Designing PCI Cards and Drivers for Power Macintosh Computers


  

Byte-Swapping Issues

Byte swapping of data is a natural consequence of address invariance. It occurs when data in one endian format is read by a system that uses the other endian format. For example, suppose the DMA descriptor values initialized by the code shown in Listing A-1 are generated by a little-endian system and saved to disk. The data is then read from the disk by a big-endian system.

Assume that the data is written to disk in byte-address order, and that the disk memory is formatted in an 8-byte wide configuration. The little-endian disk memory image would look like Figure A-5.

Figure A-5 Little-endian memory image

When read by a big-endian system in byte-address order, the data would be stored in memory as shown in Figure A-6.

Figure A-6 Big-endian memory image

Notice that the byte offsets of each field are still correct. However, the data within each field has been swapped. If field aDescr.A was read with a little-endian word loading process, the data in memory would be 0x47464544, even though the original data was written as 0x44454647.


© 1999 Apple Computer, Inc. – (Last Updated 26 March 99)