4.2.6. SWP

Swap data between registers and memory.

Use SWP to implement semaphores.

Syntax

SWP{cond}{B} Rd, Rm, [Rn]

where:

cond

is an optional condition code (see Conditional execution).

B

is an optional suffix. If B ispresent, a byte is swapped. Otherwise, a 32-bit word is swapped.

Rd

is an ARM register. Data from memory is loaded into Rd.

Rm

is an ARM register. The contents of Rm is saved to memory.

Rm can be the same register as Rd. In this case, the contents of the register is swapped with the contents of the memory location.

Rn

is an ARM register. The contents of Rn specify the address in memory with which data is to be swapped. Rn must be a different register from both Rd and Rm.

Non word-aligned addresses

Non word-aligned addresses are handled in exactly the same way as an LDR and an STR instruction (see Address alignment for word transfers).

Architectures

These instructions are available in ARM architecture versions 2a and 3 and above.

Copyright © 2000, 2001 ARM Limited. All rights reserved.ARM DUI 0068B
Non-Confidential