ssat

Signed Saturate (A32)

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

Saturates a signed value to a specified bit width.

Details

Saturates a signed integer to a specified bit width. The instruction shifts the source value by an optional amount, then saturates the result to a signed range defined by the saturation position. 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_range ← 2^(imm-1) - 1
if shifted > sat_range then
  Rd ← sat_range
  Q ← 1
else if shifted < -(2^(imm-1)) then
  Rd ← -(2^(imm-1))
  Q ← 1
else
  Rd ← shifted

Example

SSAT r0, #16, r2

Encoding

Binary Layout
cond
01101
0
1
sat_imm
Rd
imm5
0
01
Rn
 
Format Data Proc
Opcode 0x06A00010
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
0x06A00050 SSAT{<c>}{<q>} <Rd>, #<imm>, <Rn>, ASR #<amount> A32 cond | 01101 | 0 | 1 | sat_imm | Rd | imm5 | 1 | 01 | Rn
0x06A00010 SSAT{<c>}{<q>} <Rd>, #<imm>, <Rn> {, LSL #<amount>} A32 cond | 01101 | 0 | 1 | sat_imm | Rd | imm5 | 0 | 01 | Rn
0xF3200000 SSAT{<c>}{<q>} <Rd>, #<imm>, <Rn>, ASR #<amount> T32 11110 | 0 | 11 | 00 | 1 | 0 | Rn | 0 | imm3 | Rd | imm2 | 0 | sat_imm
0xF3000000 SSAT{<c>}{<q>} <Rd>, #<imm>, <Rn> {, LSL #<amount>} T32 11110 | 0 | 11 | 00 | 0 | 0 | Rn | 0 | imm3 | Rd | imm2 | 0 | sat_imm

Description

Signed Saturate saturates an optionally-shifted signed value to a selectable signed 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) = SignedSatQ(SInt(operand), saturate_to);
    R[d] = SignExtend(result, 32);
    if sat then
        PSTATE.Q = '1';