05.02.2013 Views

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Instruction Details<br />

A8.6.219 SWP, SWPB<br />

SWP (Swap) swaps a word between registers <strong>and</strong> memory. SWP loads a word from the memory address given<br />

by the value of register . The value of register is then stored to the memory address given by the<br />

value of , <strong>and</strong> the original loaded value is written to register . If the same register is specified for<br />

<strong>and</strong> , this instruction swaps the value of the register <strong>and</strong> the value at the memory address.<br />

SWPB (Swap Byte) swaps a byte between registers <strong>and</strong> memory. SWPB loads a byte from the memory address<br />

given by the value of register . The value of the least significant byte of register is stored to the<br />

memory address given by , the original loaded value is zero-extended to a 32-bit word, <strong>and</strong> the word is<br />

written to register . If the same register is specified for <strong>and</strong> , this instruction swaps the value<br />

of the least significant byte of the register <strong>and</strong> the byte value at the memory address, <strong>and</strong> clears the most<br />

significant three bytes of the register.<br />

For both instructions, the memory system ensures that no other memory access can occur to the memory<br />

location between the load access <strong>and</strong> the store access.<br />

Note<br />

The SWP <strong>and</strong> SWPB instructions rely on the properties of the system beyond the processor to ensure that<br />

no stores from other observers can occur between the load access <strong>and</strong> the store access, <strong>and</strong> this might<br />

not be implemented for all regions of memory on some system implementations. In all cases, SWP <strong>and</strong><br />

SWPB do ensure that no stores from the processor that executed the SWP or SWPB instruction can occur<br />

between the load access <strong>and</strong> the store access of the SWP or SWPB.<br />

The use of SWP is deprecated, <strong>and</strong> new code should use LDREX/STREX in preference to using SWP.<br />

The use of SWPB is deprecated, <strong>and</strong> new code should use LDREXB/STREXB in preference to using SWPB.<br />

Encoding A1 <strong>ARM</strong>v4*, <strong>ARM</strong>v5T*, <strong>ARM</strong>v6* (deprecated), <strong>ARM</strong>v7 (deprecated)<br />

SWP{B} ,,[]<br />

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0<br />

cond 0 0 0 1 0 B 0 0 Rn Rt (0)(0)(0)(0) 1 0 0 1 Rt2<br />

t = UInt(Rt); t2 = UInt(Rt2); n = UInt(Rn); size = if B == ‘1’ then 1 else 4;<br />

if t == 15 || t2 == 15 || n == 15 || n == t || n == t2 then UNPREDICTABLE;<br />

A8-432 Copyright © 1996-1998, 2000, 2004-2008 <strong>ARM</strong> Limited. All rights reserved. <strong>ARM</strong> DDI 0406B

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!