qdadd
Saturating Double and Add
QDADD<c> <Rd>, <Rm>, <Rn>
Doubles the second operand, adds to first, and saturates.
Details
Saturates the doubling of Rm, then adds the result to Rn with saturation, writing the saturated sum to Rd. The Q flag is set if saturation occurred during either the doubling or addition; other flags are unaffected. A32-only instruction requiring the Saturating Arithmetic extension; must be executed in privileged mode for certain CPSR modifications.
Pseudocode Operation
doubled ← SignedSat(Rm << 1, 32)
result ← SignedSat(Rn + doubled, 32)
Rd ← result
if (overflow during doubling or addition) then Q ← 1
Example
QDADD r0, r2, r1
Encoding
Binary Layout
cond
00010
10
0
Rn
Rd
0
0
0
0
0101
Rm
Operands
-
Rd
Destination general-purpose register -
Rm
Second source / offset general-purpose register -
Rn
First source / base general-purpose register
Reference (Arm AArch32 ISA)
Instruction Forms
| Encoding | Instruction | ISA | Bit pattern | ||
|---|---|---|---|---|---|
| 0x01400050 | QDADD{<c>}{<q>} {<Rd>,} <Rm>, <Rn> | A32 | cond | 00010 | 10 | 0 | Rn | Rd | 0 | 0 | 0 | 0 | 0101 | Rm | ||
| 0xFA80F090 | QDADD{<c>}{<q>} {<Rd>,} <Rm>, <Rn> | T32 | 111110101 | 000 | Rn | 1111 | Rd | 10 | 01 | Rm |
Description
Saturating Double and Add adds a doubled register value to another register value, and writes the result to the destination register. Both the doubling and the addition have their results saturated to the 32-bit signed integer range -231 <= x <= 231 - 1. If saturation occurs in either operation, it sets PSTATE.Q to 1.
Operation
if ConditionPassed() then
EncodingSpecificOperations();
(doubled, sat1) = SignedSatQ(2 * SInt(R[n]), 32);
boolean sat2;
(R[d], sat2) = SignedSatQ(SInt(R[m]) + SInt(doubled), 32);
if sat1 || sat2 then
PSTATE.Q = '1';