MI_SwapEndian*

C Specification

#include <nitro/mi.h>

#define MI_SwapEndian8(val) (u8)(val)
#define MI_SwapEndian16(val) (u16)((((val) & 0xFF00UL) >> 8UL) | (((val) & 0x00FFUL) << 8UL))
#define MI_SwapEndian32(val) (u32)((((val) & 0xFF000000UL) >> 24UL) | (((val) & 0x00FF0000UL) >> 8UL) | (((val) & 0x0000FF00UL) << 8UL) | (((val) & 0x000000FFUL) << 24UL))

Arguments

val The value whose endianity is to be converted.
Note: Because this is a macro, evaluation is performed several times.

Return Values

Returns a value converted to the specified endian (u16 or u32)

Description

Converts the endian of the specified 16-bit value. If little endian is detected before conversion, big endian results after conversion.
Note: Because this is a macro, arguments are evaluated several times.

These 8-bit versions do not actually perform any conversions, but they have been included for source code uniformity.

See Also

MI_Load* MI_Store* MI_HTo* MI_*ToH*

Revision History

06/13/2006 Added a description about the 8-bit versions
04/05/2006 Initial version


CONFIDENTIAL