qsub
Saturating Subtract (A32)
QSUB<c> <Rd>, <Rm>, <Rn>
Subtracts two values and saturates the result.
Pseudocode Operation
result ← Rn - Rm; if SignedOverflow(result) then Rd ← Saturate(result) else Rd ← result
Example
QSUB r0, r2, r1
Encoding
Binary Layout
cond
31:28
00010
27:23
01
22:21
0
20
Rn
19:16
Rd
15:12
0
11
0
10
0
9
0
8
0101
7:4
Rm
3:0
Operands
-
Rd
Destination general-purpose register -
Rm
Second source / offset general-purpose register -
Rn
First source / base general-purpose register
Related
More in A32 (Sat)
Reference
View in Arm A64 ISA Reference ↗
Arm AArch32 ISA
Instruction Forms
| Encoding | Instruction | ISA | Bit pattern | ||
|---|---|---|---|---|---|
| 0x01200050 | QSUB{<c>}{<q>} {<Rd>,} <Rm>, <Rn> | A32 | cond | 00010 | 01 | 0 | Rn | Rd | 0 | 0 | 0 | 0 | 0101 | Rm | ||
| 0xFA80F0A0 | QSUB{<c>}{<q>} {<Rd>,} <Rm>, <Rn> | T32 | 111110101 | 000 | Rn | 1111 | Rd | 10 | 10 | Rm |
Description
Saturating Subtract subtracts one register value from another register value, saturates the result to the 32-bit signed integer range -231 <= x <= 231 - 1, and writes the result to the destination register. If saturation occurs, it sets PSTATE.Q to 1.
Operation
if ConditionPassed() then
EncodingSpecificOperations();
boolean sat;
(R[d], sat) = SignedSatQ(SInt(R[m]) - SInt(R[n]), 32);
if sat then
PSTATE.Q = '1';