Documentation  |   Table of Contents   |  < Previous   |  Next >   |  Index

27    Byte Order Utilities

Palm OS® Programmer's API Reference

Palm OS® 68K SDK

     

These utility macros are useful when passing data back and forth between ARM code (for instance, a PNO) and 68K code.

The header file ByteOrderUtils.h declares the API that this chapter describes.

ByteOrderUtils Functions and Macros ^TOP^

EndianSwap16 Macro ^TOP^

Purpose

Byte-swap a 16-bit quantity, changing it from big-endian to little-endian or vice-versa.

Declared In

ByteOrderUtils.h

Prototype

#define EndianSwap16 (
   n
)

Parameters

n
The 16-bit quantity to be byte-swapped.

Returns

The byte-swapped equivalent of the supplied 16-bit value.

See Also

EndianSwap32()

EndianSwap32 Macro ^TOP^

Purpose

Byte-swap a 32-bit quantity, changing it from big-endian to little-endian or vice-versa.

Declared In

ByteOrderUtils.h

Prototype

#define EndianSwap32 (
   n
)

Parameters

n
The 32-bit quantity to be byte-swapped.

Returns

The byte-swapped equivalent of the supplied 32-bit value.

See Also

EndianSwap16()

Read68KUnaligned32 Macro ^TOP^

Purpose

Read a 32-bit quantity from a local variable while byte-swapping it. The address from which the 32-bit quantity is read doesn't have to be aligned on either a 2-byte or 4-byte boundary.

Declared In

ByteOrderUtils.h

Prototype

#define Read68KUnaligned32 (
   addr
)

Parameters

addr
Address from which the value is to be read.

Returns

The byte-swapped equivalent of the 32-bit value read from the supplied address.

Comments

ARM processors require that 4-byte integers be aligned on a 4-byte boundary. 68K processors require only even address (2-byte) alignment.

See Also

EndianSwap32(), Write68KUnaligned32()

Write68KUnaligned32 Macro ^TOP^

Purpose

Write a 32-bit quantity to a local variable while byte-swapping it. The address to which the 32-bit quantity is written doesn't have to be aligned on either a 2-byte or 4-byte boundary.

Declared In

ByteOrderUtils.h

Prototype

#define Write68KUnaligned32 (
   addr,
    value
)

Parameters

addr
Address to which the value is to be written.
value
The 32-bit value to be byte-swapped and written.

Returns

Nothing useful.

Comments

ARM processors require that 4-byte integers be aligned on a 4-byte boundary. 68K processors require only even address (2-byte) alignment.

See Also

EndianSwap32(), Read68KUnaligned32()