xvmsubasp

VSX Vector Multiply-Subtract Type-A Single-Precision

xvmsubasp XT,XA,XB

Performs a vector multiply-subtract operation on single-precision floating-point values.

Details

The xvmsubasp instruction performs a multiply-subtract-add operation on single-precision floating-point values in vector registers. It multiplies the elements of VSR[XA] and VSR[XT], subtracts the result from the corresponding element in VSR[XB], and adds the result to the corresponding element in VSR[XB].

Pseudocode Operation

if MSR.VSX=0 then VSX_Unavailable()
  ex_flag ←0b0
  do i = 0 to 3
    reset_xflags()
    src1 ←bfp_CONVERT_FROM_BFP32(VSR[32×AX+A].word[i])
    src2 ←bfp_CONVERT_FROM_BFP32(VSR[32×TX+T].word[i])
    src3 ←bfp_CONVERT_FROM_BFP32(VSR[32×BX+B].word[i])
    v   ←bfp_MULTIPLY_ADD(src1,src3,bfp_NEGATE(src2))
    rnd ←bfp_ROUND_TO_BFP32(FPSCR.RN,v)
    vresult.word[i] ←bfp32_CONVERT_FROM_BFP(rnd)
    if vxsnan_flag=1 then SetFX(FPSCR.VXSNAN)
    if vximz_flag=1 then SetFX(FPSCR.VXIMZ)
    if vxisi_flag=1 then SetFX(FPSCR.VXISI)
    if ox_flag=1 then SetFX(FPSCR.OX)
    if ux_flag=1 then SetFX(FPSCR.UX)
    if xx_flag=1 then SetFX(FPSCR.XX)
    ex_flag ←ex_flag | (FPSCR.VE & vxsnan_flag) | (FPSCR.VE & vximz_flag) | (FPSCR.VE & vxisi_flag) | (FPSCR.OE & ox_flag) | (FPSCR.UE & ux_flag) | (FPSCR.XE & xx_flag)
  end
  if ex_flag=0 then VSR[32×TX+T] ←result

Programming Note

The xvmsubasp instruction is commonly used for vectorized floating-point operations, particularly in scientific computing and graphics processing. Ensure that the VSX (Vector Scalar Extensions) are enabled by checking the MSR.VSX bit; otherwise, a VSX_Unavailable exception will be raised. Be cautious of alignment requirements for vector registers to avoid performance penalties or exceptions. This instruction operates at user privilege level but can generate various floating-point exceptions based on the FPSCR settings, which should be handled appropriately in error-checking code.

Example

xvmsubasp vs1, vs2, vs3

Encoding

Binary Layout
111100
0
XA
6
XT
11
XB
16
VX
21
000000
26
000000
31
000000
 
Format XX3-form
Opcode 0xF0000288
Extension VSX
Registers Altered FPSCR

Operands

  • XT
    Destination Vector Register
  • XA
    Source Vector Register A
  • XB
    Source Vector Register B
  • VX
    Target Vector Register