 |
Index for Section 9r |
|
 |
Alphabetical listing for S |
|
 |
Bottom of page |
|
swap_lw_bytes(9r)
NAME
swap_lw_bytes, swap_word_bytes, swap_words - General: Perform byte-swapping
operations
SYNOPSIS
unsigned int swap_lw_bytes(
unsigned int buffer );
unsigned int swap_word_bytes(
unsigned int buffer );
unsigned int swap_words(
unsigned int buffer );
ARGUMENTS
buffer
Specifies a 32-bit (4 bytes) quantity.
DESCRIPTION
The swap_lw_bytes interface performs a longword byte swap. The
swap_word_bytes interface performs a short word byte swap. The swap_words
interface performs a word byte swap. Many computer vendors support devices
that use a big endian model of byte ordering. Because Digital devices
support the little endian model of byte ordering, there is a need for these
byte-swapping interfaces. In addition, some buses (for example, the VMEbus)
can have specific or implied byte ordering that may require the use of
these interfaces.
Given that a longword is equal to 4 bytes; a short word is equal to 2
bytes; and 1 byte is equal to 8 bits, these interfaces swap bytes as
follows:
· The swap_lw_bytes interface takes the 32-bit quantity specified by the
buffer argument and swaps all 4 bytes.
· The swap_word_bytes interface takes the 32-bit quantity specified by
the buffer argument and swaps the individual bytes that make up each
word of the 32-bit quantity.
· The swap_words interface takes the 32-bit quantity specified by the
buffer argument and swaps the two 16-bit words.
The following illustration compares the byte swapping performed by these
interfaces.
31 0
+---+---+---+---+
Starting value: | a | b | c | d |
+---+---+---+---+
Long word byte swap
(swap_lw_bytes)
31 0
+---+---+---+---+
Ending value: | d | c | b | a |
+-------+---+---+
Short word byte swap
(swap_word_bytes)
31 0
+---+---+---+---+
Ending value: | b | a | d | c |
+---+---+---+---+
31 0
+---+---+---+---+
Starting value: | ab | cd |
+---+---+---+---+
Word byte swap
(swap_words)
31 0
+---+---+---+---+
Ending value: | cd | ab |
+---+---+---+---+
RETURN VALUES
Upon successful completion, these interfaces return the swapped bytes.
 |
Index for Section 9r |
|
 |
Alphabetical listing for S |
|
 |
Top of page |
|