4.2.14. SWP and SWPB

Swap data between registers and memory.

You can use SWP and SWPB to implement semaphores. The use of SWP and SWPB is deprecated in ARMv6 and above. See LDREX and STREX for instructions to implement more sophisticated semaphores in ARMv6 and above.

Syntax

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

where:

cond

is an optional condition code (see Conditional execution).

B

is an optional suffix. If B is present, 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.

Architectures

These ARM instructions are available in all versions of the ARM architecture.

There are no Thumb or Thumb-2 SWP or SWPB instructions.

Copyright © 2002-2005 ARM Limited. All rights reserved.ARM DUI 0204F
Non-Confidential