ARM Processor Instruction Set
ARM Processor Instruction Set
ARM Processor Instruction Set
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
5.9.1 Bytes and words<br />
<strong>ARM</strong>7500FE Data Sheet<br />
<strong>ARM</strong> DDI 0077B<br />
<strong>ARM</strong> <strong>Processor</strong> <strong>Instruction</strong> <strong>Set</strong><br />
This instruction class may be used to swap a byte (B=1) or a word (B=0) between<br />
an <strong>ARM</strong> processor register and memory. The SWP instruction is implemented as<br />
a LDR followed by a STR and the action of these is as described in the section on<br />
single data transfers. In particular, the description of Big and Little Endian<br />
configuration applies to the SWP instruction.<br />
5.9.2 Use of R15<br />
Do not use R15 as an operand (Rd, Rn or Rs) in a SWP instruction.<br />
5.9.3 Data aborts<br />
If the address used for the swap is unacceptable to the MMU, it will cause an abort.<br />
This can happen on either the read or write cycle (or both), and, in either case,<br />
the Data Abort trap will be taken. It is up to the system software to resolve the cause<br />
of the problem. The instruction can then be restarted and the original program<br />
continued.<br />
5.9.4 <strong>Instruction</strong> cycle times<br />
Swap instructions take 1 instruction fetch, 1 data read, 1 data write and 1 internal<br />
cycle. For more information see 5.17 <strong>Instruction</strong> Speed Summary on page 5-47.<br />
5.9.5 Assembler syntax<br />
{cond}{B} Rd,Rm,[Rn]<br />
{cond} two-character condition mnemonic, see Figure 5-2: Condition<br />
codes on page 5-2<br />
{B} if B is present then byte transfer, otherwise word transfer<br />
Rd,Rm,Rn are expressions evaluating to valid register numbers<br />
5.9.6 Examples<br />
SWP R0,R1,[R2] ;load R0 with the word addressed by R2, and<br />
;store R1 at R2<br />
SWPB R2,R3,[R4] ;load R2 with the byte addressed by R4, and<br />
;store bits 0 to 7 of R3 at R4<br />
SWPEQ R0,R0,[R1] ;conditionally swap the contents of R1<br />
;with R0<br />
Open Access - Preliminary<br />
5-33