usat
Unsigned Saturate (A32)
USAT<c> <Rd>, #<imm>, <Rm> {, <shift>}
Saturates an unsigned value to a specified bit width.
Pseudocode Operation
shifted ← Rm << shift_amount
sat_max ← 2^imm - 1
if shifted > sat_max then
Rd ← sat_max
Q ← 1
else if shifted < 0 then
Rd ← 0
Q ← 1
else
Rd ← shifted
Example
USAT r0, #16, r2
Encoding
Binary Layout
cond
31:28
01101
27:23
1
22
1
21
sat_imm
20:16
Rd
15:12
imm5
11:7
0
6
01
5:4
Rn
3:0
Operands
-
Rd
Destination general-purpose register -
imm
Bit Position -
Rm
Second source / offset general-purpose register
Related
More in A32 (DSP)
Reference
View in Arm A64 ISA Reference ↗
Arm AArch32 ISA
Instruction Forms
| Encoding | Instruction | ISA | Bit pattern | ||
|---|---|---|---|---|---|
| 0x06E00050 | USAT{<c>}{<q>} <Rd>, #<imm>, <Rn>, ASR #<amount> | A32 | cond | 01101 | 1 | 1 | sat_imm | Rd | imm5 | 1 | 01 | Rn | ||
| 0x06E00010 | USAT{<c>}{<q>} <Rd>, #<imm>, <Rn> {, LSL #<amount>} | A32 | cond | 01101 | 1 | 1 | sat_imm | Rd | imm5 | 0 | 01 | Rn | ||
| 0xF3A00000 | USAT{<c>}{<q>} <Rd>, #<imm>, <Rn>, ASR #<amount> | T32 | 11110 | 0 | 11 | 10 | 1 | 0 | Rn | 0 | imm3 | Rd | imm2 | 0 | sat_imm | ||
| 0xF3800000 | USAT{<c>}{<q>} <Rd>, #<imm>, <Rn> {, LSL #<amount>} | T32 | 11110 | 0 | 11 | 10 | 0 | 0 | Rn | 0 | imm3 | Rd | imm2 | 0 | sat_imm |
Description
Unsigned Saturate saturates an optionally-shifted signed value to a selected unsigned range. This instruction sets PSTATE.Q to 1 if the operation saturates.
Operation
if ConditionPassed() then
EncodingSpecificOperations();
operand = Shift(R[n], shift_t, shift_n, PSTATE.C); // PSTATE.C ignored
(result, sat) = UnsignedSatQ(SInt(operand), saturate_to);
R[d] = ZeroExtend(result, 32);
if sat then
PSTATE.Q = '1';