01.12.2014 Views

ARM Processor Instruction Set

ARM Processor Instruction Set

ARM Processor Instruction Set

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.

<strong>ARM</strong> <strong>Processor</strong> <strong>Instruction</strong> <strong>Set</strong><br />

5.3 Branch and branch with link (B, BL)<br />

These instructions are only executed if the condition is true. The instruction encoding<br />

is shown in ➲Figure 5-3: Branch instructions.<br />

Branch instructions contain a signed 2's complement 24-bit offset. This is shifted left<br />

two bits, sign extended to 32 bits, and added to the PC. The instruction can therefore<br />

specify a branch of +/- 32Mbytes. The branch offset must take account of the prefetch<br />

operation, which causes the PC to be 2 words (8 bytes) ahead of the current<br />

instruction.<br />

31 28 27 25 24 23 0<br />

Cond 101 L offset<br />

Link bit<br />

0 = Branch<br />

1 = Branch with Link<br />

Condition field<br />

Preliminary - Unrestricted<br />

5.3.1 The link bit<br />

5.3.2 <strong>Instruction</strong> cycle times<br />

Figure 5-3: Branch instructions<br />

Branches beyond +/- 32Mbytes must use an offset or absolute destination which has<br />

been previously loaded into a register. In this case the PC should be manually saved<br />

in R14 if a branch with link type operation is required.<br />

Branch with Link (BL) writes the old PC into the link register (R14) of the current bank.<br />

The PC value written into R14 is adjusted to allow for the prefetch, and contains the<br />

address of the instruction following the branch and link instruction. Note that the CPSR<br />

is not saved with the PC.<br />

To return from a routine called by Branch with Link use MOV PC,R14 if the link register<br />

is still valid or use LDM Rn!,{..PC} if the link register has been saved onto a stack<br />

pointed to by Rn.<br />

Branch and Branch with Link instructions take 3 instruction fetches. For more<br />

information see ➲5.16.7 <strong>Instruction</strong> speed summary on page 5-55.<br />

5-4<br />

<strong>ARM</strong>7500 Data Sheet<br />

<strong>ARM</strong> DDI 0050C

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

Saved successfully!

Ooh no, something went wrong!