usat16
Unsigned Saturate 16 (A32)
USAT16<c> <Rd>, #<imm>, <Rm>
Saturates two unsigned 16-bit values.
Details
Saturates two unsigned 16-bit halfword values packed in a register to a specified bit width. The upper and lower 16-bit values are independently saturated to the range [0, 2^imm–1]. Sets the Q flag if either halfword saturates; N, Z, C, V flags are unaffected. A32-only instruction requiring DSP extension.
Pseudocode Operation
lower_hw ← Rm[15:0] (unsigned)
upper_hw ← Rm[31:16] (unsigned)
sat_max ← 2^imm - 1
if lower_hw > sat_max then
Rd[15:0] ← sat_max
Q ← 1
else
Rd[15:0] ← lower_hw
if upper_hw > sat_max then
Rd[31:16] ← sat_max
Q ← 1
else
Rd[31:16] ← upper_hw
Example
USAT16 r0, #16, r2
Encoding
Binary Layout
cond
01101
1
10
sat_imm
Rd
1
1
1
1
0011
Rn
Operands
-
Rd
Destination general-purpose register -
imm
Bit Position -
Rm
Second source / offset general-purpose register
Reference (Arm AArch32 ISA)
Instruction Forms
| Encoding | Instruction | ISA | Bit pattern | ||
|---|---|---|---|---|---|
| 0x06E00F30 | USAT16{<c>}{<q>} <Rd>, #<imm>, <Rn> | A32 | cond | 01101 | 1 | 10 | sat_imm | Rd | 1 | 1 | 1 | 1 | 0011 | Rn | ||
| 0xF3A00000 | USAT16{<c>}{<q>} <Rd>, #<imm>, <Rn> | T32 | 11110 | 0 | 11 | 10 | 1 | 0 | Rn | 0 | 000 | Rd | 00 | 0 | 0 | sat_imm |
Description
Unsigned Saturate 16 saturates two signed 16-bit values to a selected unsigned range.
This instruction sets PSTATE.Q to 1 if the operation saturates.
Operation
if ConditionPassed() then
EncodingSpecificOperations();
(result1, sat1) = UnsignedSatQ(SInt(R[n]<15:0>), saturate_to);
(result2, sat2) = UnsignedSatQ(SInt(R[n]<31:16>), saturate_to);
R[d]<15:0> = ZeroExtend(result1, 16);
R[d]<31:16> = ZeroExtend(result2, 16);
if sat1 || sat2 then
PSTATE.Q = '1';