Chapter 8 Details of Usage
Byte and Word Swapping | Page 8 - 3 |
Byte and Word Swapping
The RF3880 adapter is flexible enough to allow you to request Byte Swapping, Word Swapping, or both, during transfers of command structures.
This section will first give you some examples to explain why the swapping feature is offered to you, then provide a perspective on implementation with the RF3880 for both Command Structures used by the RF3880 (which the adapter can swap) and data (which needs special software if swapping is necessary).
Need for Swapping
The memory architecture of your system depends on the type of processor you are using. There are several major manufacturers that each use different arrangements of bytes, words, and
Example of Memory Differences
If you were to define the following variables in a program:
char byte[] = “test”;
int word[2] = {0x0102, 0x0304}; double dword = 0xAABBCCDD;
They would appear this way in memory (beginning at location n) for each respective format:
variable | Byte # of memory |
| Intel Order |
|
| Motorola Order |
| ||
byte | n | t | e | s | t | t | e | s | t |
|
|
|
|
|
|
|
|
|
|
word | n + 4 | 02 | 01 | 04 | 03 | 01 | 02 | 03 | 04 |
|
|
|
|
|
|
|
|
|
|
dword | n + 8 | DD | CC | BB | AA | AA | BB | CC | DD |
|
|
|
|
|
|
|
|
|
|
Table 108: Variations in Intel and Motorola Memory
Essentially the two processors store a string of bytes in the same order. However, the bytes that make up word and
The RF3880 adapter must correctly access the command structures for either type of processor.
Processor Type | Byte of word or | Order in memory | |
|
| ||
Motorola | LSB* | stored in highest memory address | |
|
| ||
MSB* | stored in lowest memory address | ||
| |||
|
|
| |
Intel | LSB | stored in lowest memory address | |
|
| ||
MSB | stored in highest memory address | ||
| |||
|
|
|
Table 109: Explanation of Memory Storage Differences
Throughout this manual, the Parameter and Status Blocks that make up the command structures are represented
If you have an Intel processor, you will need to translate these displays to your format. The following example will help explain this.
User’s Guide | 21020285 D |