# MI_Swap*

## Syntax

  `#include <nitro/mi.h>`
  `u32 MI_SwapWord( u32 setData, volatile u32* destp );`
  `u8 MI_SwapByte( u32 setData, volatile u8* destp );`

## Arguments

setData | The data that is set
destp | Pointer to the swap destination

## Return Values

Value stored in the swap destination immediately prior to the swap.

## Description

This function swaps `setData` and the data stored at *`destp`. This function implements spinlock to exclusively control resources that are shared between processors or modules. `MI_SwapByte()` swaps byte data. `MI_SwapWord()` swaps word data.

Note that byte access to the main memory is possible only via cache in the TEG environment. Therefore, `MI_SwapWord()` should be used for main memory.

## Internal Operation

This swaps using the ARM instructions `swp` or `swpb`.

## See Also

None.

## Revision History

2004/10/18 Corrected the description of byte access.
2004/02/10 Initial version.

CONFIDENTIAL