is
an optional suffix. If B is present, a byte
is swapped. Otherwise, a 32-bit word is swapped.
Rt
is the destination register. Rt must
not be PC.
Rt2
is the source register. Rt2 can
be the same register as Rt. Rt2 must
not be PC.
Rn
contains the address in memory. Rn must
be a different register from both Rt and Rt2. Rn must
not be PC.
Usage
You can use SWP and SWPB to implement
semaphores:
Data from memory is loaded into Rt.
The contents of Rt2 is
saved to memory.
If Rt2 is
the same register as Rt,
the contents of the register is swapped with the contents of the
memory location.
Note
The use of SWP and SWPB is deprecated
in ARMv6 and above. You can use LDREX and STREX instructions
to implement more sophisticated semaphores in ARMv6 and above.
Architectures
These ARM instructions are available in all versions of the
ARM architecture.
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.