smlatb

Signed Multiply Accumulate (Top x Bottom)

SMLATB<c> <Rd>, <Rn>, <Rm>, <Ra>

Accumulates (Rn.T * Rm.B) into Ra.

Details

Signed multiply-accumulate of the top 16-bit halfword of Rn and the bottom 16-bit halfword of Rm, with the 32-bit product added to Ra and stored in Rd. This is an A32 DSP instruction that operates on 16-bit subregisters. The Q flag may be set if overflow occurs during accumulation, but N, Z, C, V flags are unchanged.

Pseudocode Operation

temp ← SignExtend(Rn[31:16], 32) * SignExtend(Rm[15:0], 32);
result ← temp + Ra;
if OverflowFrom_Addition(temp, Ra) then Q ← 1; end if;
Rd ← result;

Example

SMLATB r0, r1, r2, r5

Encoding

Binary Layout
cond
00010
00
0
Rd
Ra
Rm
1
0
1
0
Rn
 
Format Multiply
Opcode 0x010000A0
Extension A32 (DSP)

Operands

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

Reference (Arm AArch32 ISA)

Instruction Forms

Encoding Instruction ISA Bit pattern
0x010000A0 SMLATB{<c>}{<q>} <Rd>, <Rn>, <Rm>, <Ra> A32 cond | 00010 | 00 | 0 | Rd | Ra | Rm | 1 | 0 | 1 | 0 | Rn
0xFB100020 SMLATB{<c>}{<q>} <Rd>, <Rn>, <Rm>, <Ra> T32 111110110 | 001 | Rn | Ra | Rd | 00 | 1 | 0 | Rm

Description

Signed Multiply Accumulate (halfwords) performs a signed multiply accumulate operation. The multiply acts on two signed 16-bit quantities, taken from either the bottom or the top half of their respective source registers. The other halves of these source registers are ignored. The 32-bit product is added to a 32-bit accumulate value and the result is written to the destination register. If overflow occurs during the addition of the accumulate value, the instruction sets PSTATE.Q to 1. It is not possible for overflow to occur during the multiplication.

Operation

if ConditionPassed() then
    EncodingSpecificOperations();
    operand1 = if n_high then R[n]<31:16> else R[n]<15:0>;
    operand2 = if m_high then R[m]<31:16> else R[m]<15:0>;
    result = SInt(operand1) * SInt(operand2) + SInt(R[a]);
    R[d] = result<31:0>;
    if result != SInt(result<31:0>) then  // Signed overflow
        PSTATE.Q = '1';