msub

Multiply-Subtract

MSUB <Wd>, <Wn>, <Wm>, <Wa>

Calculates (Ra - (Rn * Rm)).

Details

Multiplies Wn by Wm and subtracts the result from Wa, storing the result in Wd. All intermediate values are computed with full 64-bit precision before truncating to 32 bits. No condition flags are affected. This is an AArch64-only instruction that does not generate any exceptions.

Pseudocode Operation

temp ← Wa - (Wn × Wm)
Wd ← temp[31:0]

Example

MSUB w0, w1, w2, w5

Encoding

Binary Layout
0
00
11011
000
Rm
1
Ra
Rn
Rd
 
Format Data Processing
Opcode 0x1B008000
Extension Base

Operands

  • Wd
    Destination 32-bit integer register
  • Wn
    First source / base 32-bit integer register
  • Wm
    Second source / offset 32-bit integer register
  • Wa
    Minuend

Reference (Arm A64 ISA)

Instruction Forms

Encoding Instruction ISA Bit pattern
0x1B008000 MSUB <Wd>, <Wn>, <Wm>, <Wa> A64 0 | 00 | 11011 | 000 | Rm | 1 | Ra | Rn | Rd
0x9B008000 MSUB <Xd>, <Xn>, <Xm>, <Xa> A64 1 | 00 | 11011 | 000 | Rm | 1 | Ra | Rn | Rd

Description

Multiply-Subtract multiplies two register values, subtracts the product from a third register value, and writes the result to the destination register.

Operation

bits(destsize) operand1 = X[n, destsize];
bits(destsize) operand2 = X[m, destsize];
bits(destsize) operand3 = X[a, destsize];

integer result;

result = UInt(operand3) - (UInt(operand1) * UInt(operand2));
X[d, destsize] = result<destsize-1:0>;