ARM Instruction Reference
4-22 Copyright © 2000, 2001 ARM Limited. All rights reserved. ARM DUI 0068B
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 on page 4-4).
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
.
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 on page 4-10).
Architectures
These instructions are available in ARM architecture versions 2a and 3 and above.