usat

Unsigned Saturate (A32)

USAT<c> <Rd>, #<imm>, <Rm> {, <shift>}

Saturates an unsigned value to a specified bit width.

Details

Saturates an unsigned integer to a specified bit width. The instruction shifts the source value by an optional amount, then saturates the result to an unsigned range [0, 2^imm–1]. Sets the Q flag if saturation occurs; N, Z, C, V flags are unaffected. A32-only instruction requiring DSP extension.

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
01101
1
1
sat_imm
Rd
imm5
0
01
Rn
 
Format Data Proc
Opcode 0x06E00010
Extension A32 (DSP)

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
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';