ssat16

Signed Saturate 16 (A32)

SSAT16<c> <Rd>, #<imm>, <Rm>

Saturates two signed 16-bit values.

Details

Saturates two signed 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 [-(2^(imm-1)), 2^(imm-1)–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] (signed)
upper_hw ← Rm[31:16] (signed)
sat_range ← 2^(imm-1) - 1
sat_min ← -(2^(imm-1))
if lower_hw > sat_range or lower_hw < sat_min then
  Rd[15:0] ← Clamp(lower_hw, sat_min, sat_range)
  Q ← 1
else
  Rd[15:0] ← lower_hw
if upper_hw > sat_range or upper_hw < sat_min then
  Rd[31:16] ← Clamp(upper_hw, sat_min, sat_range)
  Q ← 1
else
  Rd[31:16] ← upper_hw

Example

SSAT16 r0, #16, r2

Encoding

Binary Layout
cond
01101
0
10
sat_imm
Rd
1
1
1
1
0011
Rn
 
Format Data Proc
Opcode 0x06A00F30
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
0x06A00F30 SSAT16{<c>}{<q>} <Rd>, #<imm>, <Rn> A32 cond | 01101 | 0 | 10 | sat_imm | Rd | 1 | 1 | 1 | 1 | 0011 | Rn
0xF3200000 SSAT16{<c>}{<q>} <Rd>, #<imm>, <Rn> T32 11110 | 0 | 11 | 00 | 1 | 0 | Rn | 0 | 000 | Rd | 00 | 0 | 0 | sat_imm

Description

Signed Saturate 16 saturates two signed 16-bit values to a selected signed range. This instruction sets PSTATE.Q to 1 if the operation saturates.

Operation

if ConditionPassed() then
    EncodingSpecificOperations();
    (result1, sat1) = SignedSatQ(SInt(R[n]<15:0>), saturate_to);
    (result2, sat2) = SignedSatQ(SInt(R[n]<31:16>), saturate_to);
    R[d]<15:0> = SignExtend(result1, 16);
    R[d]<31:16> = SignExtend(result2, 16);
    if sat1 || sat2 then
        PSTATE.Q = '1';