qsub16
Saturating Subtract 16
QSUB16<c> <Rd>, <Rn>, <Rm>
Parallel saturating subtract of 2 signed halfwords.
Details
Performs parallel saturating subtraction of two signed 16-bit halfwords in Rm from Rn, storing results in Rd. Each halfword is independently saturated to the signed 16-bit range [−32768, 32767] if underflow occurs. No condition flags are affected. Execution restricted to A32 with DSP extension; requires ARMv6 or later.
Pseudocode Operation
Rd[31:16] ← SignedSat(Rn[31:16] − Rm[31:16], 16)
Rd[15:0] ← SignedSat(Rn[15:0] − Rm[15:0], 16)
Example
QSUB16 r0, r1, r2
Encoding
Binary Layout
cond
01100
010
Rn
Rd
1
1
1
1
0
11
1
Rm
Operands
-
Rd
Destination general-purpose register -
Rn
First source / base general-purpose register -
Rm
Second source / offset general-purpose register
Reference (Arm AArch32 ISA)
Instruction Forms
| Encoding | Instruction | ISA | Bit pattern | ||
|---|---|---|---|---|---|
| 0x06200F70 | QSUB16{<c>}{<q>} {<Rd>,} <Rn>, <Rm> | A32 | cond | 01100 | 010 | Rn | Rd | 1 | 1 | 1 | 1 | 0 | 11 | 1 | Rm | ||
| 0xFAD0F010 | QSUB16{<c>}{<q>} {<Rd>,} <Rn>, <Rm> | T32 | 111110101 | 101 | Rn | 1111 | Rd | 0 | 0 | 0 | 1 | Rm |
Description
Saturating Subtract 16 performs two 16-bit integer subtractions, saturates the results to the 16-bit signed integer range -215 <= x <= 215 - 1, and writes the results to the destination register.
Operation
if ConditionPassed() then
EncodingSpecificOperations();
diff1 = SInt(R[n]<15:0>) - SInt(R[m]<15:0>);
diff2 = SInt(R[n]<31:16>) - SInt(R[m]<31:16>);
R[d]<15:0> = SignedSat(diff1, 16);
R[d]<31:16> = SignedSat(diff2, 16);