shadd16

Signed Halving Add 16

SHADD16<c> <Rd>, <Rn>, <Rm>

Signed add and halving (average) of 2 halfwords.

Details

Performs parallel addition of two signed 16-bit halfwords from Rn and Rm, then arithmetically shifts each result right by 1 bit (halving), storing in Rd. No saturation occurs; results are always in the range [−32768, 32767]. No condition flags are affected. Execution restricted to A32 with DSP extension; requires ARMv6 or later.

Pseudocode Operation

Rd[31:16] ← (SignExtend(Rn[31:16]) + SignExtend(Rm[31:16])) >> 1
Rd[15:0] ← (SignExtend(Rn[15:0]) + SignExtend(Rm[15:0])) >> 1

Example

SHADD16 r0, r1, r2

Encoding

Binary Layout
cond
01100
011
Rn
Rd
1
1
1
1
0
00
1
Rm
 
Format SIMD Integer
Opcode 0x06300F10
Extension A32 (DSP)

Operands

  • Rd
    Destination general-purpose register
  • Rn
    First source / base general-purpose register
  • Rm
    Second source / offset general-purpose register

Reference (Arm AArch32 ISA)

Instruction Forms

Encoding Instruction ISA Bit pattern
0x06300F10 SHADD16{<c>}{<q>} {<Rd>,} <Rn>, <Rm> A32 cond | 01100 | 011 | Rn | Rd | 1 | 1 | 1 | 1 | 0 | 00 | 1 | Rm
0xFA90F020 SHADD16{<c>}{<q>} {<Rd>,} <Rn>, <Rm> T32 111110101 | 001 | Rn | 1111 | Rd | 0 | 0 | 1 | 0 | Rm

Description

Signed Halving Add 16 performs two signed 16-bit integer additions, halves the results, and writes the results to the destination register.

Operation

if ConditionPassed() then
    EncodingSpecificOperations();
    sum1 = SInt(R[n]<15:0>) + SInt(R[m]<15:0>);
    sum2 = SInt(R[n]<31:16>) + SInt(R[m]<31:16>);
    R[d]<15:0>  = sum1<16:1>;
    R[d]<31:16> = sum2<16:1>;