The Cortex-M4 Instruction Set
ARM DUI 0553A
Copyright © 2010 ARM. All rights reserved.
3-13
ID121610
Non-Confidential
Instruction substitution
Your assembler might be able to produce an equivalent instruction in cases where you specify a
constant that is not permitted. For example, an assembler might assemble the instruction
CMP
Rd
,
#0xFFFFFFFE
as the equivalent instruction
CMN
Rd
,
#0x2
.
Register with optional shift
You specify an Operand2 register in the form:
Rm
{,
shift
}
where:
Rm
The register holding the data for the second operand.
shift
An optional shift to be applied to
Rm
. It can be one of:
ASR #
n
Arithmetic shift right
n
bits, 1
≤
n
≤
32.
LSL #
n
Logical shift left
n
bits, 1
≤
n
≤
31.
LSR #
n
Logical shift right
n
bits, 1
≤
n
≤
32.
ROR #
n
Rotate right
n
bits, 1
≤
n
≤
31.
RRX
Rotate right one bit, with extend.
-
If omitted, no shift occurs, equivalent to
LSL #0
.
If you omit the shift, or specify
LSL #0
, the instruction uses the value in
Rm
.
If you specify a shift, the shift is applied to the value in
Rm
, and the resulting 32-bit value is used
by the instruction. However, the contents in the register
Rm
remains unchanged. Specifying a
register with shift also updates the carry flag when used with certain instructions. For
information on the shift operations and how they affect the carry flag, see
3.3.4
Shift Operations
Register shift operations move the bits in a register left or right by a specified number of bits,
the
shift length
. Register shift can be performed:
•
directly by the instructions
ASR
,
LSR
,
LSL
,
ROR
, and
RRX
, and the result is written to a
destination register
•
during the calculation of
Operand2
by the instructions that specify the second operand as a
register with shift, see
. The result is used by the
instruction.
The permitted shift lengths depend on the shift type and the instruction, see the individual
instruction description or
. If the shift length is 0, no shift
occurs. Register shift operations update the carry flag except when the specified shift length is
0. The following sub-sections describe the various shift operations and how they affect the carry
flag. In these descriptions,
Rm
is the register containing the value to be shifted, and
n
is the shift
length.
ASR
Arithmetic shift right by
n
bits moves the left-hand
32
-
n
bits of the register
Rm
, to the right by
n
places, into the right-hand
32
-
n
bits of the result. And it copies the original bit[31] of the register
into the left-hand
n
bits of the result. See