Cortex-M3 Processor (Reference Material)
UG0331 User Guide Revision 15.0
61
3.6.4.3.3
Restrictions
In these instructions:
•
Rn
must not be PC
•
Rm
must not be SP and must not be PC
•
Rt
can be SP only for word loads and word stores
•
Rt
can be PC only for word loads.
When
Rt
is PC in a word load instruction:
•
Bit[0] of the loaded value must be 1 for correct execution, and a branch occurs to this halfword-
aligned address
•
If the instruction is conditional, it must be the last instruction in the IT block.
3.6.4.3.4
Condition Flags
These instructions do not change the flags.
Examples
STR R0, [R5, R1] ; Store value of R0 into an address equal to
; sum of R5 and R1
LDRSB R0, [R5, R1, LSL #1] ; Read byte value from an address equal to
; sum of R5 and two times R1, sign extended it
; to a word value and put it in R0
STR R0, [R1, R2, LSL #2] ; Stores R0 to an address equal to sum of R1
; and four times R2.
3.6.4.4
LDR and STR, Unprivileged
Load and Store with unprivileged access.
3.6.4.4.1
Syntax
op{type}T{cond} Rt, [Rn {, #offset}]
; immediate offset
where:
•
op
is either LDR (load register) or STR (store register)
•
type
is one of:
•
B: unsigned byte, zero extend to 32 bits on loads.
•
SB: signed byte, sign extend to 32 bits (LDR only).
•
H: unsigned halfword, zero extend to 32 bits on loads.
•
SH: signed halfword, sign extend to 32 bits (LDR only).
•
-: omit, for word.
•
cond
is an optional condition code, refer to
•
Rt
is the register to load or store.
•
Rn
is the register on which the memory address is based.
•
offset
is an offset from Rn and can be 0 to 255. If offset is omitted, the address is the value in Rn.
3.6.4.4.2
Operation
These load and store instructions perform the same function as the memory access instructions with
immediate offset, refer to
LDR and STR, Immediate Offset,
4
. The difference is that these
instructions have only unprivileged access even when used in privileged software.
When used in unprivileged software, these instructions behave in exactly the same way as normal
memory access instructions with immediate offset.