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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Writing to the PC<br />

In <strong>ARM</strong>v7, instruction writes to the PC are h<strong>and</strong>led as follows:<br />

The System Level Programmers’ Model<br />

Exception return instructions write both the PC <strong>and</strong> the CPSR. The value written to the CPSR<br />

determines the new instruction set state, <strong>and</strong> the value written to the PC determines the address that<br />

is branched to. For full details, including which instructions are exception return instructions <strong>and</strong> how<br />

incorrectly aligned PC values are h<strong>and</strong>led, see Exception return on page B1-38.<br />

The following two 16-bit Thumb instruction encodings remain in Thumb state <strong>and</strong> branch to a value<br />

written to the PC:<br />

— encoding T2 of ADD (register) on page A8-24<br />

— encoding T1 of MOV (register) on page A8-196.<br />

The value written to the PC is forced to be halfword-aligned by ignoring its least significant bit,<br />

instead treating that bit as being 0.<br />

The following instructions remain in the same instruction set state <strong>and</strong> branch to a value written to<br />

the PC:<br />

— B, BL, CBNZ, CBZ, CHKA, HB, HBL, HBLP, HBP, TBB, <strong>and</strong> TBH<br />

— in ThumbEE state, load/store instructions that fail their null check.<br />

The definition of each of these instructions ensures that the value written to the PC is correctly<br />

aligned for the current instruction set state.<br />

The BLX (immediate) instruction switches between <strong>ARM</strong> <strong>and</strong> Thumb states <strong>and</strong> branches to a value<br />

written to the PC. Its definition ensures that the value written to the PC is correctly aligned for the<br />

new instruction set state.<br />

The following instructions write a value to the PC, treating that value as an interworking address with<br />

low-order bits that determine the new instruction set state <strong>and</strong> an address to branch to:<br />

— BLX (register), BX, <strong>and</strong> BXJ<br />

— LDR, <strong>and</strong> LDRT instructions with equal to the PC<br />

— POP <strong>and</strong> all forms of LDM except LDM (exception return), when the register list includes the PC<br />

— in <strong>ARM</strong> state only, ADC, ADD, ADR, AND, ASR (immediate), BIC, EOR, LSL (immediate), LSR<br />

(immediate), MOV, MVN, ORR, ROR (immediate), RRX, RSB, RSC, SBC, <strong>and</strong> SUB instructions with <br />

equal to the PC <strong>and</strong> without flag setting specified.<br />

For details of how an interworking address specifies the new instruction set state <strong>and</strong> instruction<br />

address, see Pseudocode details of operations on <strong>ARM</strong> core registers on page A2-12.<br />

Note<br />

— The LDR, LDRT, POP, <strong>and</strong> LDM instructions first have this behavior in <strong>ARM</strong>v5T.<br />

— The instructions listed as having this behavior in <strong>ARM</strong> state only first have this behavior in<br />

<strong>ARM</strong>v7.<br />

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

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

Saved successfully!

Ooh no, something went wrong!