Encoding:

SPECIAL3

011111

0

00000

rt

rd

ABSQ_S.PH

01001

ABSQ_S.PH

010010

6

5

5

5

5

6

Format:

ABSQ_S.PH  rd, rt

MIPSDSP

Find Absolute Value of Two Fractional Halfwords

Purpose:

Find Absolute Value of Two Fractional Halfwords

Find the absolute value of each of a pair of Q15 fractional halfword values with 16-bit saturation.

Description:

rd = sign_extend(sat16(abs(rt31..16))) || sat16(abs(rt15..0))

For each value in the right-most pair of Q15 fractional halfword values in register rt, the absolute value is found and written to the corresponding Q15 halfword in register rd. If either input value is the minimum Q15 value (-1.0 in decimal, 0x8000 in hexadecimal), the corresponding result is saturated to 0x7FFF. The upper 32 bits of register rt are ignored.

The sign of the left-most halfword result is extended into the 32 most-significant bits of the destination register.

This instruction sets bit 20 in the DSPControl register in the ouflag field if either input value was saturated.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = satAbs16( GPR[rt]31..16 )
tempA15..0 = satAbs16( GPR[rt]15..0 )
GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
function satAbs16( a15..0 )
   if ( a15..0 = 0x8000 ) then
      DSPControlouflag:20 = 1
      temp15..0 = 0x7FFF
   else
      if ( a15 = 1 ) then
          temp15..0 = -a15..0
      else
         temp15..0 = a15..0
      endif
   endif
   return temp15..0 
endfunction satAbs16

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

rt

rd

ABSQ_S.QB

00001

ABSQ_S.PH

010010

6

5

5

5

5

6

Format:

ABSQ_S.QB rd, rt

MIPSDSP-R2

Find Absolute Value of Four Fractional Byte Values

Purpose:

Find Absolute Value of Four Fractional Byte Values

Find the absolute value of four fractional byte vector elements with saturation.

Description:

rd = sign_extend(sat8(abs(rt31..24)) || sat8(abs(rt23..16)) || sat8(abs(rt15..8)) || sat8(abs(rt7..0)))

For each value in the four right-most Q7 fractional byte elements in register rt, the absolute value is found and written to the corresponding byte in register rd. If either input value is the minimum Q7 value (-1.0 in decimal, 0x80 in hexadecimal), the corresponding result is saturated to 0x7F. The upper 32 bits of register rts are ignored.

The sign of the left-most byte result is extended into the 32 most-significant bits of destination register rdt.

This instruction sets bit 20 in ouflag field of the DSPControl register if any input value was saturated.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempD7..0 = abs8( GPR[rt]31..24 )
tempC7..0 = abs8( GPR[rt]23..16 )
tempB7..0 = abs8( GPR[rt]15..8 )
tempA7..0 = abs8( GPR[rt]7..0 )
GPR[rd]63..0 = (tempD7)32 || tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0
function abs8( a7..0 )
   if ( a7..0 = 0x80 ) then
      DSPControlouflag:20 = 1
      temp7..0 = 0x7F
   else
      if ( a7 = 1 ) then
          temp7..0 = -a7..0
      else
         temp7..0 = a7..0
      endif
   endif
   return temp7..0 
endfunction abs8

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

rt

rd

ABSQ_S.W

10001

ABSQ_S.PH

010010

6

5

5

5

5

6

Format:

ABSQ_S.W  rd, rt

MIPSDSP

Find Absolute Value of Fractional Word

Purpose:

Find Absolute Value of Fractional Word

Find the absolute value of a fractional Q31 value with 32-bit saturation.

Description:

rd = sign_extend(sat32(abs(rt31..0)))

The absolute value of the right-most Q31 fractional value in register rt is found, sign-extended to 64 bits, and written to destination register rd. If the input value is the minimum Q31 value (-1.0 in decimal, 0x80000000 in hexadecimal), the result is saturated to 0x7FFFFFFF before being sign-extended and written to register rd.

This instruction sets bit 20 in the DSPControl register in the ouflag field if the input value was saturated.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

temp31..0 = satAbs32( GPR[rt]31..0 )
GPR[rd]63..0 = (temp31)32 || temp31..0
function satAbs32( a31..0 )
   if ( a31..0 = 0x80000000 ) then
      DSPControlouflag:20 = 1
      temp31..0 = 0x7FFFFFFF
   else
      if ( a31 = 1 ) then
          temp31..0 = -a31..0
      else
         temp31..0 = a31..0
      endif
   endif
   return temp31..0 
endfunction satAbs32

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

ADDQH.PH

01000

ADDUH.QB

011000

SPECIAL3

011111

rs

rt

rd

ADDQH_R.PH

01010

ADDUH.QB

011000

6

5

5

5

5

6

Format:

ADDQH[_R].PH 

Add Fractional Halfword Vectors And Shift Right to Halve Results

ADDQH.PH     rd, rs, rt

MIPSDSP-R2

Add Fractional Halfword Vectors And Shift Right to Halve Results

ADDQH_R.PH   rd, rs, rt

MIPSDSP-R2

Add Fractional Halfword Vectors And Shift Right to Halve Results

Purpose:

Add Fractional Halfword Vectors And Shift Right to Halve Results

Element-wise fractional addition of halfword vectors, with a right shift by one bit to halve each result, with optional rounding.

Description:

rd = sign_extend(round((rs31..16 + rt31..16) >> 1) || round((rs15..0 + rt15..0) >> 1))

Each element from the two right-most halfword values in register rs is added to the corresponding halfword element in register rt to create an interim 17-bit result.

In the non-rounding instruction variant, each interim result is then shifted right by one bit before being written to the corresponding halfword element of destination register rd.

In the rounding version of the instruction, a value of 1 is added at the least-significant bit position of each interim result; the interim result is then right-shifted by one bit and written to the destination register.

This instruction does not modify the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

ADDQH.PH:
   tempB15..0 = rightShift1AddQ16( GPR[rs]31..16 , GPR[rt]31..16 )
   tempA15..0 = rightShift1AddQ16( GPR[rs]15..0 , GPR[rt]15..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
ADDQH_R.PH:
   tempB15..0 = roundRightShift1AddQ16( GPR[rs]31..16 , GPR[rt]31..16 )
   tempA15..0 = roundRightShift1AddQ16( GPR[rs]15..0 , GPR[rt]15..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
function rightShift1AddQ16( a15..0 , b15..0 )
   temp16..0 = (( a15 || a15..0 ) + ( b15 || b15..0 ))
   return temp16..1
endfunction rightShift1AddQ16
function roundRightShift1AddQ16( a15..0 , b15..0 )
   temp16..0 = (( a15 || a15..0 ) + ( b15 || b15..0 ))
   temp16..0 = temp16..0 + 1
   return temp16..1
endfunction roundRightShift1AddQ16

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

ADDQH.W

10000

ADDUH.QB

011000

SPECIAL3

011111

rs

rt

rd

ADDQH_R.W

10010

ADDUH.QB

011000

6

5

5

5

5

6

Format:

ADDQH[_R].W 

Add Fractional Words And Shift Right to Halve Results

ADDQH.W     rd, rs, rt

MIPSDSP-R2

Add Fractional Words And Shift Right to Halve Results

ADDQH_R.W   rd, rs, rt

MIPSDSP-R2

Add Fractional Words And Shift Right to Halve Results

Purpose:

Add Fractional Words And Shift Right to Halve Results

Fractional addition of word vectors, with a right shift by one bit to halve the result, with optional rounding.

Description:

rd = sign_extend(round((rs31..0 + rt31..0) >> 1))

The right-most word in register rs is added to the right-most word in register rt to create an interim 33-bit result.

In the non-rounding instruction variant, the interim result is then shifted right by one bit before being written to the destination register rd.

In the rounding version of the instruction, a value of 1 is added at the least-significant bit position of the interim result; the interim result is then right-shifted by one bit and written to the destination register.

This instruction does not modify the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

ADDQH.W:
   tempA31..0 = rightShift1AddQ32( GPR[rs]31..0 , GPR[rt]31..0 )
   GPR[rd]63..0 = (tempB15)32 || tempA31..0
ADDQH_R.W:
   tempA31..0 = roundRightShift1AddQ32( GPR[rs]31..0 , GPR[rt]31..0 )
   GPR[rd]63..0 = (tempB15)32 || tempA31..0
function rightShift1AddQ32( a31..0 , b31..0 )
   temp32..0 = (( a31 || a31..0 ) + ( b31 || b31..0 ))
   return temp32..1
endfunction rightShift1AddQ32
function roundRightShift1AddQ32( a31..0 , b31..0 )
   temp32..0 = (( a31 || a31..0 ) + ( b31 || b31..0 ))
   temp32..0 = temp32..0 + 1
   return temp32..1
endfunction roundRightShift1AddQ32

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

ADDQ.PH

01010

ADDU.QB

010000

SPECIAL3

011111

rs

rt

rd

ADDQ_S.PH

01110

ADDU.QB

010000

6

5

5

5

5

6

Format:

ADDQ[_S].PH 

Add Fractional Halfword Vectors

ADDQ.PH   rd, rs, rt

MIPSDSP

Add Fractional Halfword Vectors

ADDQ_S.PH rd, rs, rt

MIPSDSP

Add Fractional Halfword Vectors

Purpose:

Add Fractional Halfword Vectors

Element-wise addition of two vectors of Q15 fractional values to produce a vector of Q15 fractional results, with optional saturation.

Description:

rd = sign_extend(sat16(rs31..16 + rt31..16) || sat16(rs15..0 + rt15..0))

Each of the two right-most fractional halfword elements in register rt are added to the corresponding fractional halfword elements in register rs.

For the non-saturating version of the instruction, the result of each addition is written into the corresponding element in register rd. If the addition results in overflow or underflow, the result modulo 2 is written to the corresponding element in register rd.

For the saturating version of the instruction, signed saturating arithmetic is performed, where an overflow is clamped to the largest representable value (0x7FFF hexadecimal) and an underflow to the smallest representable value

(0x8000 hexadecimal) before being written to the destination register rd.

For each instruction, the sign of the left-most halfword result is extended into the 32 most-significant bits of the destination register.

For each instruction, if either of the individual additions result in underflow, overflow, or saturation, a 1 is written to bit 20 in the DSPControl register in the ouflag field.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

ADDQ.PH:
   tempB15..0 = add16( GPR[rs]31..16 , GPR[rt]31..16 )
   tempA15..0 = add16( GPR[rs]15..0 , GPR[rt]15..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
ADDQ_S.PH:
   tempB15..0 = satAdd16( GPR[rs]31..16 , GPR[rt]31..16 )
   tempA15..0 = satAdd16( GPR[rs]15..0 , GPR[rt]15..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
function add16( a15..0, b15..0 ) 
   temp16..0 = ( a15 || a15..0 ) + ( b15 || b15..0 )
   if ( temp16 != temp15 ) then
      DSPControlouflag:20 = 1
   endif
   return temp15..0
endfunction add16
function satAdd16( a15..0, b15..0 )
   temp16..0 = ( a15 || a15..0 ) + ( b15 || b15..0 )
   if ( temp16 != temp15 ) then
      if ( temp16 = 0 ) then
          temp15..0 = 0x7FFF
      else
          temp15..0 = 0x8000
      endif
      DSPControlouflag:20 = 1
   endif
   return temp15..0
endfunction satAdd16

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

ADDQ_S.W

10110

ADDU.QB

010000

6

5

5

5

5

6

Format:

ADDQ_S.W rd, rs, rt

MIPSDSP

Add Fractional Words

Purpose:

Add Fractional Words

Addition of two Q31 fractional values to produce a Q31 fractional result, with saturation.

Description:

rd = sign_extend(sat32(rs31..0 + rt31..0))

The right-most Q31 fractional word in register rt is added to the corresponding fractional word in register rs. The result is then sign-extended to 64 bits and written to the destination register rd.

Signed saturating arithmetic is used, where an overflow is clamped to the largest representable value (0x7FFFFFFF hexadecimal) and an underflow to the smallest representable value (0x80000000 hexadecimal) before being signextended and written to the destination register rd.

If the addition results in underflow, overflow, or saturation, a 1 is written to bit 20 in the DSPControl register within the ouflag field.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

temp31..0 = satAdd32( GPR[rs]31..0 , GPR[rt]31..0 )
GPR[rd]63..0 = (temp31)32 || temp31..0
function satAdd32( a31..0, b31..0 )
   temp32..0 = ( a31 || a31..0 ) + ( b31 || b31..0 )
   if ( temp32 != temp31 ) then
      if ( temp32 = 0 ) then
          temp31..0 = 0x7FFFFFFF
      else
          temp31..0 = 0x80000000
      endif
      DSPControlouflag:20 = 1
   endif
   return temp31..0
endfunction satAdd32

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

ADDSC

10000

ADDU.QB

010000

6

5

5

5

5

6

Format:

ADDSC rd, rs, rt

MIPSDSP

Add Signed Word and Set Carry Bit

Purpose:

Add Signed Word and Set Carry Bit

Add two signed 32-bit values and set the carry bit in the DSPControl register if the addition generates a carry-out bit.

Description:

DSPControl[c],rd = sign_extend(rs + rt)

The right-most 32-bit signed value in register rt is added to the right-most 32-bit signed value in register rs. The result is then sign-extended to 64 bits and written into register rd. The carry bit result out of the addition operation is written to bit 13 (the c field) of the DSPControl register.

This instruction does not modify the ouflag field in the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

Operation:

temp32..0 = ( 0 || GPR[rs]31..0 ) + ( 0 || GPR[rt]31..0 )
DSPControlc:13 = temp32 
GPR[rd]63..0 = (temp31)32 || temp31..0

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

Note that this is really two's complement (modulo) arithmetic on the two integer values, where the overflow is preserved in architectural state. The ADDWC instruction can be used to do an add using this carry bit. These instructions are provided in the MIPS32 ISA to support 64-bit addition and subtraction using two pairs of 32-bit GPRs to hold each 64-bit value. In the MIPS64 ISA, 64-bit addition and subtraction can be performed directly, without requiring the use of these instructions.

Encoding:

SPECIAL3

011111

rs

rt

rd

ADDUH

00000

ADDUH.QB

011000

SPECIAL3

011111

rs

rt

rd

ADDUH_R

00010

ADDUH.QB

011000

6

5

5

5

5

6

Format:

ADDUH[_R].QB 

Unsigned Add Vector Quad-Bytes And Right Shift to Halve Results

ADDUH.QB     rd, rs, rt

MIPSDSP-R2

Unsigned Add Vector Quad-Bytes And Right Shift to Halve Results

ADDUH_R.QB   rd, rs, rt

MIPSDSP-R2

Unsigned Add Vector Quad-Bytes And Right Shift to Halve Results

Purpose:

Unsigned Add Vector Quad-Bytes And Right Shift to Halve Results

Element-wise unsigned addition of unsigned byte vectors, with right shift by one bit to halve each result, with optional rounding.

Description:

rd = round((rs31..24 + rt31..24)>>1) || round((rs23..16 + rt23..16)>>1) ||round((rs15..8 + rt15..8)>>1) || round((rs7..0 + rt7..0)>>1)

Each element from the four unsigned byte values in register rs is added to the corresponding unsigned byte element in register rt to create an unsigned interim result.

In the non-rounding instruction variant, each interim result is then shifted right by one bit before being written to the corresponding unsigned byte element of destination register rd.

In the rounding version of the instruction, a value of 1 is added at the least-significant bit position of each interim result before being right-shifted by one bit and written to the destination register.

This instruction does not modify the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

ADDUH.QB:
   tempD7..0 = rightShift1AddU8( GPR[rs]31..24 , GPR[rt]31..24 )
   tempC7..0 = rightShift1AddU8( GPR[rs]23..16 , GPR[rt]23..16 )
   tempB7..0 = rightShift1AddU8( GPR[rs]15..8 , GPR[rt]15..8 )
   tempA7..0 = rightShift1AddU8( GPR[rs]7..0 , GPR[rt]7..0 )
   GPR[rd]63..0 = (tempD7)32 || tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0
ADDUH_R.QB:
   tempD7..0 = roundRightShift1AddU8( GPR[rs]31..24 , GPR[rt]31..24 )
   tempC7..0 = roundRightShift1AddU8( GPR[rs]23..16 , GPR[rt]23..16 )
   tempB7..0 = roundRightShift1AddU8( GPR[rs]15..8 , GPR[rt]15..8 )
   tempA7..0 = roundRightShift1AddU8( GPR[rs]7..0 , GPR[rt]7..0 )
   GPR[rd]63..0 = (tempD7)32 || tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0
function rightShift1AddU8( a7..0 , b7..0 )
   temp8..0 = (( 0 || a7..0 ) + ( 0 || b7..0 ))
   return temp8..1
endfunction rightShift1AddU8
function roundRightShift1AddU8( a7..0 , b7..0 )
   temp8..0 = (( 0 || a7..0 ) + ( 0 || b7..0 ))
   temp8..0 = temp8..0 + 1
   return temp8..1
endfunction roundRightShift1AddU8

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

ADDU.PH

01000

ADDU.QB

010000

SPECIAL3

011111

rs

rt

rd

ADDU_S.PH

01100

ADDU.QB

010000

6

5

5

5

5

6

Format:

ADDU[_S].PH 

Unsigned Add Integer Halfwords

ADDU.PH   rd, rs, rt

MIPSDSP-R2

Unsigned Add Integer Halfwords

ADDU_S.PH rd, rs, rt

MIPSDSP-R2

Unsigned Add Integer Halfwords

Purpose:

Unsigned Add Integer Halfwords

Add two pairs of unsigned integer halfwords, with optional saturation.

Description:

rd = sign_extend(sat16(rs31..16 + rt31..16) || sat16(rs15..0 + rt15..0))

The two right-most unsigned integer halfword elements in register rt are added to the corresponding unsigned integer halfword elements in register rs.

For the non-saturating version of the instruction, the result modulo 65,536 is written into the corresponding element in register rd.

For the saturating version of the instruction, the addition is performed using unsigned saturating arithmetic. Results that overflow are clamped to the largest representable value (65,535 decimal, 0xFFFF hexadecimal) before being written to the destination register rd.

Bit 31 of the result is extended into the 32 most-significant bits of the destination register.

For either instruction, if any of the individual additions result in overflow or saturation, a 1 is written to bit 20 in the

DSPControl register within the ouflag field.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

ADDU.PH:
   tempB15..0 = addU16( GPR[rs]31..16 , GPR[rt]31..16 )
   tempA15..0 = addU16( GPR[rs]15..0 , GPR[rt]15..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
ADDU_S.PH:
   tempB15..0 = satAddU16( GPR[rs]31..16 , GPR[rt]31..16 )
   tempA15..0 = satAddU16( GPR[rs]15..0 , GPR[rt]15..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

ADDU.QB

00000

ADDU.QB

010000

SPECIAL3

011111

rs

rt

rd

ADDU_S.QB

00100

ADDU.QB

010000

6

5

5

5

5

6

Format:

ADDU[_S].QB 

Unsigned Add Quad Byte Vectors

ADDU.QB   rd, rs, rt

MIPSDSP

Unsigned Add Quad Byte Vectors

ADDU_S.QB rd, rs, rt

MIPSDSP

Unsigned Add Quad Byte Vectors

Purpose:

Unsigned Add Quad Byte Vectors

Element-wise addition of two vectors of unsigned byte values to produce a vector of unsigned byte results, with optional saturation.

Description:

rd = sign_extend(sat8(rs31..24 + rt31..24)) || sat8(rs23..16 + rt23..16) || sat8(rs15..8 + rt15..8) || sat8(rs7..0 + rt7..0)

The four right-most byte elements in register rt are added to the corresponding byte elements in register rs.

For the non-saturating version of the instruction, the result modulo 256 is written into the corresponding element in register rd.

For the saturating version of the instruction, the addition is performed using unsigned saturating arithmetic. Results that overflow are clamped to the largest representable value (255 decimal, 0xFF hexadecimal) before being written to the destination register rd.

Bit 31 of the result is extended into the 32 most-significant bits of the destination register.

For either instruction, if any of the individual additions result in overflow or saturation, a 1 is written to bit 20 in the

DSPControl register within the ouflag field.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

ADDU.QB:
   tempD7..0 = addU8( GPR[rs]31..24 , GPR[rt]31..24 )
   tempC7..0 = addU8( GPR[rs]23..16 , GPR[rt]23..16 )
   tempB7..0 = addU8( GPR[rs]15..8 , GPR[rt]15..8 )
   tempA7..0 = addU8( GPR[rs]7..0 , GPR[rt]7..0 )
   GPR[rd]63..0 = (tempD7)48 || tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0
ADDU_S.QB:
   tempD7..0 = satAddU8( GPR[rs]31..24 , GPR[rt]31..24 )
   tempC7..0 = satAddU8( GPR[rs]23..16 , GPR[rt]23..16 )
   tempB7..0 = satAddU8( GPR[rs]15..8 , GPR[rt]15..8 )
   tempA7..0 = satAddU8( GPR[rs]7..0 , GPR[rt]7..0 )
   GPR[rd]63..0 = (tempD7)48 || tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0
function addU8( a7..0, b7..0 )
   temp8..0 = ( 0 || a7..0 ) + ( 0 || b7..0 )
   if ( temp8 = 1 ) then
      DSPControlouflag:20 = 1
   endif
   return temp7..0
endfunction addU8
function satAddU8( a7..0, b7..0 )
   temp8..0 = ( 0 || a7..0 ) + ( 0 || b7..0 )
   if ( temp8 = 1 ) then
      temp7..0 = 0xFF
      DSPControlouflag:20 = 1
   endif
   return temp7..0
endfunction satAddU8

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

ADDWC

10001

ADDU.QB

010000

6

5

5

5

5

6

Format:

ADDWC rd, rs, rt

MIPSDSP

Add Word with Carry Bit

Purpose:

Add Word with Carry Bit

Add two signed 32-bit values with the carry bit in the DSPControl register.

Description:

rd = sign_extend(rs + rt + DSPControlc:13)

The right-most 32-bit value in register rt is added to the right-most 32-bit value in register rs and the carry bit in the

DSPControl register. The result is then sign-extended to 64 bits and written to destination register rd.

If the addition results in either overflow or underflow, this instruction writes a 1 to bit 20 in the ouflag field of the

DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

Operation:

temp32..0 = ( GPR[rs]31 || GPR[rs]31..0 ) + ( GPR[rt]31 || GPR[rt]31..0 ) + ( 032 || 
DSPControlc:13 )
if ( temp32 != temp31 ) then
   DSPControlouflag:20 = 1
endif
GPR[rd]63..0 = (temp31)32 || temp31..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

sa

APPEND

00000

APPEND

110001

6

5

5

5

5

6

Format:

APPEND rt, rs, sa

MIPSDSP-R2

Left Shift and Append Bits to the LSB

Purpose:

Left Shift and Append Bits to the LSB

Shift a general-purpose register left, inserting bits from the another GPR into the bit positions emptied by the shift.

Description:

rt = sign_extend((rt31..0 << sa4..0) || rssa-1..0

The right-most 32-bit value in register rt is left-shifted by the specified shift amount sa, and sa bits from the least-significant positions of the rs register are inserted into the bit positions in rt emptied by the shift. The 32-bit shifted value is sign-extended to 64 bits and written to destination register rt.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

if ( sa4..0 = 0 ) then 
   temp31..0 = GPR[rt]31..0 
else
   temp31..0 = ( GPR[rt]31-sa..0 || GPR[rs]sa-1..0 )
endif
GPR[rt]63..0 = (temp31)32 || temp31..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

bp

BALIGN

10000

APPEND

110001

6

5

5

3

2

5

6

Format:

BALIGN rt, rs, bp

MIPSDSP-R2

Byte Align Contents from Two Registers

Purpose:

Byte Align Contents from Two Registers

Create a word result by combining a specified number of bytes from each of two source registers.

Description:

rt = sign_extend((rt << 8*bp) || (rs >> 8*(4-bp)))

The right-most 32-bit word in register rt is left-shifted as a 32-bit value by bp byte positions, and the right-most word in register rs is right-shifted as a 32-bit value by (4-bp) byte positions. The shifted values are then or-ed together to create a 32-bit result that is sign-extended to 64 bits and written to destination register rt.

The argument bp is provided by the instruction, and is interpreted as an unsigned two-bit integer taking values between zero and three.

Restrictions:

No data-dependent exceptions are possible.

Operation:

if (bp1..0 = 0) or (bp1..0 = 2) then
   GPR[rt]63..0 = UNPREDICTABLE
else 
   temp31..0 = ( GPR[rt]31..0 << (8*bp1..0) ) || ( GPR[rs]31..0 >> (8*(4-bp1..0)) )
   GPR[rt]63..0 = (temp31)32 || temp31..0
endif

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

rt

rd

BITREV

11011

ABSQ_S.PH

010010

6

5

5

5

5

6

Format:

BITREV rd, rt

MIPSDSP

Bit-Reverse Halfword

Purpose:

Bit-Reverse Halfword

To reverse the order of the bits of the least-significant halfword in the specified register.

Description:

rd = zero_extend(rt0..15)

The right-most halfword value in register rt is bit-reversed into the right-most halfword position in the destination register rd. The 48 most-significant bits of the destination register are zero-filled.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

temp15..0 = GPR[rt]0..15
GPR[rd]63..0 = 048 || temp15..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

REGIMM

000001

0

BPOSGE32C

11000

offset

6

5

5

16

Format:

BPOSGE32C offset

MIPSDSP-R3

Branch on Greater Than or Equal To Value 32 inDSPControl Pos Field

Purpose:

Branch on Greater Than or Equal To Value 32 inDSPControl Pos Field

Perform a PC-relative branch if the value of the pos field in the DSPControl register is greater than or equal to 32.

Description:

 if (DSPControlpos:6..0 >= 32) then goto PC+offset

First, the offset argument is left-shifted by two bits to form an 18-bit signed integer value. This value is added to the address of the instruction immediately following the branch to form a target branch address. Then, if the value of the pos field of the DSPControl register is greater than or equal to 32, the branch is taken and execution begins from the target address.

Restrictions:

If a control transfer instruction (CTI) is executed in the forbidden slot of a branch or jump, Release 6 implementations are required to signal a Reserved Instruction Exception. A CTI is considered to be one of the following instructions: branch, jump, NAL (Release 6), ERET, ERETNC (Release 5), DERET, WAIT, or PAUSE (Release 2). An instruction is in the forbidden slot if it is the instruction following the branch.

Availability:

This instruction is introduced by and required as of Revision 3 of the DSP Module.

Operation:

I:     se_offsetGPRLEN..0 = ( offset15 )GPRLEN-18 || offset15..0 || 02
      branch_condition = ( DSPControlpos:6..0 >= 32 ? 1 : 0 )
I+1:  if ( branch_condition = 1 ) then
          PCGPRLEN..0 = PCGPRLEN..0 + se_offsetGPRLEN..0
      endif

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

With the 18-bit signed instruction offset, the conditional branch range is ±128 Kbytes. Use jump (J) or jump register

(JR) instructions to branch to addresses outside of this range.

Encoding:

REGIMM

000001

0

BPOSGE32

11100

offset

6

5

5

16

Format:

BPOSGE32 offset

MIPSDSP

Branch on Greater Than or Equal To Value 32 inDSPControl Pos Field

Purpose:

Branch on Greater Than or Equal To Value 32 inDSPControl Pos Field

Perform a PC-relative branch if the value of the pos field in the DSPControl register is greater than or equal to 32.

Description:

 if (DSPControlpos:6..0 >= 32) then goto PC+offset

First, the offset argument is left-shifted by two bits to form an 18-bit signed integer value. This value is added to the address of the instruction immediately following the branch to form a target branch address. Then, if the value of the pos field of the DSPControl register is greater than or equal to 32, the branch is taken and execution begins from the target address after the instruction in the branch delay slot has been executed.

Restrictions:

Pre-Release 6: Processor operation is UNPREDICTABLE if a control transfer instruction (CTI), specifically a branch, jump, NAL (Release 6), ERET, ERETNC (Release 5), DERET, WAIT, or PAUSE (Release 2) instruction is placed in the delay slot of a branch or jump.

Release 6: If a control transfer instruction (CTI) is executed in the delay slot of a branch or jump, Release 6 implementations are required to a signal a Reserved Instruction Exception.

Availability:

None.

Operation:

I:     se_offsetGPRLEN..0 = ( offset15 )GPRLEN-18 || offset15..0 || 02
      branch_condition = ( DSPControlpos:6..0 >= 32 ? 1 : 0 )
I+1:  if ( branch_condition = 1 ) then
          PCGPRLEN..0 = PCGPRLEN..0 + se_offsetGPRLEN..0
      endif

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

With the 18-bit signed instruction offset, the conditional branch range is ±128 Kbytes. Use jump (J) or jump register

(JR) instructions to branch to addresses outside of this range.

Encoding:

SPECIAL3

011111

rs

rt

0

00000

CMP.EQ.PH

01000

CMPU.EQ.QB

010001

SPECIAL3

011111

rs

rt

0

00000

CMP.LT.PH

01001

CMPU.EQ.QB

010001

SPECIAL3

011111

rs

rt

0

00000

CMP.LEPH

01010

CMPU.EQ.QB

010001

6

5

5

5

5

6

Format:

CMP.cond.PH 

Compare Vectors of Signed Integer Halfword Values

CMP.EQ.PH  rs, rt

MIPSDSP

Compare Vectors of Signed Integer Halfword Values

CMP.LT.PH  rs, rt

MIPSDSP

Compare Vectors of Signed Integer Halfword Values

CMP.LE.PH  rs, rt

MIPSDSP

Compare Vectors of Signed Integer Halfword Values

Purpose:

Compare Vectors of Signed Integer Halfword Values

Perform an element-wise comparison of two vectors of two signed integer halfwords, recording the results of the comparison in condition code bits.

Description:

DSPControlccond:25..24 = (rs31..16 cond rt31..16) || (rs15..0 cond rt15..0)

The two right-most signed integer halfword elements in register rs are compared with the corresponding signed integer halfword element in register rt. The two 1-bit boolean comparison results are written to bits 24 and 25 of the

DSPControl register's 8-bit condition code field. The values of the six remaining condition code bits (bits 26 through

31 of the DSPControl register) are UNPREDICTABLE.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

CMP.EQ.PH:
   ccB = GPR[rs]31..16 EQ GPR[rt]31..16 
   ccA = GPR[rs]15..0 EQ GPR[rt]15..0 
   DSPControlccond:25..24 = ccB || ccA
   DSPControlccond:31..26 = UNPREDICTABLE
CMP.LT.PH:
   ccB = GPR[rs]31..16 LT GPR[rt]31..16 
   ccA = GPR[rs]15..0 LT GPR[rt]15..0 
   DSPControlccond:25..24 = ccB || ccA
   DSPControlccond:31..26 = UNPREDICTABLE
CMP.LE.PH:
   ccB = GPR[rs]31..16 LE GPR[rt]31..16 
   ccA = GPR[rs]15..0 LE GPR[rt]15..0 
   DSPControlccond:25..24 = ccB || ccA
   DSPControlccond:31..26 = UNPREDICTABLE

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

CMPGDU.EQ.QB

11000

CMPU.EQ.QB

010001

SPECIAL3

011111

rs

rt

rd

CMPGDU.LT.QB

11001

CMPU.EQ.QB

010001

SPECIAL3

011111

rs

rt

rd

CMPGDU.LE.QB

11010

CMPU.EQ.QB

010001

6

5

5

5

5

6

Format:

CMPGDU.cond.QB 

Compare Unsigned Vector of Four Bytes and Write Result to GPR and DSPControl

CMPGDU.EQ.QB  rd, rs, rt

MIPSDSP-R2

Compare Unsigned Vector of Four Bytes and Write Result to GPR and DSPControl

CMPGDU.LT.QB  rd, rs, rt

MIPSDSP-R2

Compare Unsigned Vector of Four Bytes and Write Result to GPR and DSPControl

CMPGDU.LE.QB  rd, rs, rt 

MIPSDSP-R2

Compare Unsigned Vector of Four Bytes and Write Result to GPR and DSPControl

Purpose:

Compare Unsigned Vector of Four Bytes and Write Result to GPR and DSPControl

Compare two vectors of four unsigned bytes each, recording the comparison results in condition code bits that are written to both the specified destination GPR and the condition code bits in the DSPControl register.

Description:

DSPControl[ccond]27..24 = (rs31..24 cond rt31..24) || (rs23..16 cond rt23..16) || (rs15..8 cond rt15..8) || (rs7..0 cond rt7..0);
rd = 0(GPRLEN-4) || DSPControl[ccond]27..24 

Each of the four right-most unsigned byte elements in register rs are compared with the corresponding unsigned byte elements in register rt. The four 1-bit boolean comparison results are written to the four least-significant bits of destination register rd and to bits 24 through 27 of the DSPControl register's 8-bit condition code field. The remaining bits in destination register rd are set to zero. The value of bits 28 through 31 of the DSPControl register's condition code field are UNPREDICTABLE.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

CMPGDU.EQ.QB:
   ccD = GPR[rs]31..24 EQ GPR[rt]31..24 
   ccC = GPR[rs]23..16 EQ GPR[rt]23..16 
   ccB = GPR[rs]15..8 EQ GPR[rt]15..8 
   ccA = GPR[rs]7..0 EQ GPR[rt]7..0 
   DSPControlcc:27..24 = ccD || ccC || ccB || ccA
   DSPControlccond:31..28 = UNPREDICTABLE
   GPR[rd]63..0 = 0(GPRLEN-4) || ccD || ccC || ccB || ccA
CMPGDU.LT.QB:
   ccD = GPR[rs]31..24 LT GPR[rt]31..24 
   ccC = GPR[rs]23..16 LT GPR[rt]23..16 
   ccB = GPR[rs]15..8 LT GPR[rt]15..8 
   ccA = GPR[rs]7..0 LT GPR[rt]7..0 
   DSPControlcc:27..24 = ccD || ccC || ccB || ccA
   DSPControlccond:31..28 = UNPREDICTABLE
   GPR[rd]63..0 = 0(GPRLEN-4) || ccD || ccC || ccB || ccA
CMPGDU.LE.QB:
   ccD = GPR[rs]31..24 LE GPR[rt]31..24 
   ccC = GPR[rs]23..16 LE GPR[rt]23..16 
   ccB = GPR[rs]15..8 LE GPR[rt]15..8 
   ccA = GPR[rs]7..0 LE GPR[rt]7..0 
   DSPControlcc:27..24 = ccD || ccC || ccB || ccA
   DSPControlccond:31..28 = UNPREDICTABLE
   GPR[rd]63..0 = 0(GPRLEN-4) || ccD || ccC || ccB || ccA

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

CMPGU.EQ.QB

00100

CMPU.EQ.QB

010001

SPECIAL3

011111

rs

rt

rd

CMPGU.LT.QB

00101

CMPU.EQ.QB

010001

SPECIAL3

011111

rs

rt

rd

CMPGU.LE.QB

00110

CMPU.EQ.QB

010001

6

5

5

5

5

6

Format:

CMPGU.cond.QB 

Compare Vectors of Unsigned Byte Values and Write Results to a GPR

CMPGU.EQ.QB  rd, rs, rt

MIPSDSP

Compare Vectors of Unsigned Byte Values and Write Results to a GPR

CMPGU.LT.QB  rd, rs, rt

MIPSDSP

Compare Vectors of Unsigned Byte Values and Write Results to a GPR

CMPGU.LE.QB  rd, rs, rt

MIPSDSP

Compare Vectors of Unsigned Byte Values and Write Results to a GPR

Purpose:

Compare Vectors of Unsigned Byte Values and Write Results to a GPR

Perform an element-wise comparison of two vectors of unsigned bytes, recording the results of the comparison in condition code bits that are written to the specified GPR.

Description:

rd = 060 || (rs31..24 cond rt31..24) || (rs23..16 cond rt23..16) || (rs15..8 cond rt15..8) || (rs7..0 cond rt7..0)

Each of the four right-most unsigned byte elements in register rs are compared with the corresponding unsigned byte elements in register rt. The four 1-bit boolean comparison results are written to the four least-significant bits of destination register rd. The remaining bits in rd are set to zero.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

CMPGU.EQ.QB:
   ccD = GPR[rs]31..24 EQ GPR[rt]31..24 
   ccC = GPR[rs]23..16 EQ GPR[rt]23..16 
   ccB = GPR[rs]15..8 EQ GPR[rt]15..8 
   ccA = GPR[rs]7..0 EQ GPR[rt]7..0 
   GPR[rd]63..0 = 0(GPRLEN-4) || ccD || ccC || ccB || ccA
CMPGU.LT.QB:
   ccD = GPR[rs]31..24 LT GPR[rt]31..24 
   ccC = GPR[rs]23..16 LT GPR[rt]23..16 
   ccB = GPR[rs]15..8 LT GPR[rt]15..8 
   ccA = GPR[rs]7..0 LT GPR[rt]7..0 
   GPR[rd]63..0 = 0(GPRLEN-4) || ccD || ccC || ccB || ccA
CMPGU.LE.QB:
   ccD = GPR[rs]31..24 LE GPR[rt]31..24 
   ccC = GPR[rs]23..16 LE GPR[rt]23..16 
   ccB = GPR[rs]15..8 LE GPR[rt]15..8 
   ccA = GPR[rs]7..0 LE GPR[rt]7..0 
   GPR[rd]63..0 = 0(GPRLEN-4) || ccD || ccC || ccB || ccA

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

00000

CMPU.EQ.QB

00000

CMPU.EQ.QB

010001

SPECIAL3

011111

rs

rt

0

00000

CMPU.LT.QB

00001

CMPU.EQ.QB

010001

SPECIAL3

011111

rs

rt

0

00000

CMPU.LE.QB

00010

CMPU.EQ.QB

010001

6

5

5

5

5

6

Format:

CMPU.cond.QB 

Compare Vectors of Unsigned Byte Values

CMPU.EQ.QB  rs, rt

MIPSDSP

Compare Vectors of Unsigned Byte Values

CMPU.LT.QB  rs, rt

MIPSDSP

Compare Vectors of Unsigned Byte Values

CMPU.LE.QB  rs, rt

MIPSDSP

Compare Vectors of Unsigned Byte Values

Purpose:

Compare Vectors of Unsigned Byte Values

Perform an element-wise comparison of two vectors of four unsigned bytes, recording the results of the comparison in condition code bits.

Description:

DSPControlccond:27..24 = (rs31..24 cond rt31..24) || (rs23..16 cond rt23..16) || (rs15..8 cond rt15..8) || (rs7..0 cond rt7..0)

Each of the four right-most unsigned byte elements in register rs are compared with the corresponding unsigned byte elements in register rt. The four 1-bit boolean comparison results are written to bits 24 through 27 of the DSPControl register's 8-bit condition code field. The value of bits 28 through 31 of the DSPControl register's condition code field are UNPREDICTABLE.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

CMPU.EQ.QB:
   ccD = GPR[rs]31..24 EQ GPR[rt]31..24 
   ccC = GPR[rs]23..16 EQ GPR[rt]23..16 
   ccB = GPR[rs]15..8 EQ GPR[rt]15..8 
   ccA = GPR[rs]7..0 EQ GPR[rt]7..0 
   DSPControlccond:27..24 = ccD || ccC || ccB || ccA
   DSPControlccond:31..28 = UNPREDICTABLE
CMPU.LT.QB:
   ccD = GPR[rs]31..24 LT GPR[rt]31..24 
   ccC = GPR[rs]23..16 LT GPR[rt]23..16 
   ccB = GPR[rs]15..8 LT GPR[rt]15..8 
   ccA = GPR[rs]7..0 LT GPR[rt]7..0 
   DSPControlccond:27..24 = ccD || ccC || ccB || ccA
   DSPControlccond:31..28 = UNPREDICTABLE
CMPU.LE.QB:
   ccD = GPR[rs]31..24 LE GPR[rt]31..24 
   ccC = GPR[rs]23..16 LE GPR[rt]23..16 
   ccB = GPR[rs]15..8 LE GPR[rt]15..8 
   ccA = GPR[rs]7..0 LE GPR[rt]7..0 
   DSPControlccond:27..24 = ccD || ccC || ccB || ccA
   DSPControlccond:31..28 = UNPREDICTABLE

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

DPA.W.PH

00000

DPA.W.PH

110000

6

5

5

3

2

5

6

Format:

DPA.W.PH ac, rs, rt

MIPSDSP-R2

Dot Product with Accumulate on Vector Integer Halfword Elements

Purpose:

Dot Product with Accumulate on Vector Integer Halfword Elements

Generate the dot-product of two integer halfword vector elements using full-size intermediate products and then accumulate into the specified accumulator register.

Description:

ac = ac + ((rs31..16 * rt31..16) + (rs15..0 * rt15..0))

Each of the two halfword integer values from register rt is multiplied with the corresponding halfword element from register rs to create two integer word results. These two products are summed to generate a dot-product result, which is then accumulated into the specified 64-bit HI/LO accumulator, creating a 64-bit integer result.

The value of ac selects an accumulator numbered from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture.

This instruction does not set any bits of the ouflag field in the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the result is UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB31..0 = (GPR[rs]31..16 * GPR[rt]31..16)
tempA31..0 = (GPR[rs]15..0 * GPR[rt]15..0)
dotp32..0 = ( tempB31 || tempB31..0 ) + ( tempA31 || tempA31..0 )
acc63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) + ( (dotp32)31 || dotp32..0 )
( HI[ac]63..0 || LO[ac]63..0 ) = (acc63)32 || acc63..32 || (acc31)32 || acc31..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

DPAQX_S.W.PH

11000

DPA.W.PH

110000

6

5

5

3

2

5

6

Format:

DPAQX_S.W.PH ac, rs, rt 

MIPSDSP-R2

Cross Dot Product with Accumulation on Fractional Halfword Elements

Purpose:

Cross Dot Product with Accumulation on Fractional Halfword Elements

Element-wise cross multiplication of two vectors of fractional halfword elements and accumulation of the 32-bit intermediate products into the specified 64-bit accumulator register, with saturation.

Description:

ac = ac + (sat32(rs31..16 * rt15..0) + sat32(rs15..0 * rt31..16))

The left of the right-most Q15 fractional word values from registers rt is multiplied with the right halfword element from register rs and the result left-shifted by one bit position to generate a Q31 fractional format intermediate product. Similarly, the right of the right-most Q15 fractional word values from registers rt is multiplied with the left halfword element from register rs and the result left-shifted by one bit position to generate a Q31 fractional format intermediate product. If both multiplicands for either of the multiplications are equal to -1.0 (0x8000 hexadecimal), the resulting intermediate product is saturated to the maximum positive Q31 fractional value (0x7FFFFFFF hexadecimal).

The two intermediate products are then sign-extended and summed to generate a 64-bit, Q32.31 fractional format dotproduct result that is accumulated into the specified 64-bit HI/LO accumulator to produce a final Q32.31 fractional result.

The value of ac can range from 0 to 3; a value of 0 refers to the original HI/LO register pair of the MIPS64 architecture.

If saturation occurs as a result of a halfword multiplication, a 1 is written to one of bits 16 through 19 of the

DSPControl register, within the ouflag field. The value of ac determines which of these bits is set: bit 16 corresponds

to ac0, bit 17 to ac1, bit 18 to ac2, and bit 19 to ac3.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the result is UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB31..0 = multiplyQ15Q15( ac, GPR[rs]31..16, GPR[rt]15..0 )
tempA31..0 = multiplyQ15Q15( ac, GPR[rs]15..0, GPR[rt]31..16 )
dotp63..0 = ( (tempB31)32 || tempB31..0 ) + ( (tempA31)32 || tempA31..0 )
tempC63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) + dotp63..0
( HI[ac]63..0 || LO[ac]63..0 ) = (tempC63)32 || tempC63..32 || (tempC31)32 || tempC31..0
function multiplyQ15Q15( acc1..0, a15..0, b15..0 )
   if ( a15..0 = 0x8000 ) and ( b15..0 = 0x8000 ) then
      temp31..0 = 0x7FFFFFFF
      DSPControlouflag:16+acc = 1
   else
      temp31..0 = ( a15..0 * b15..0 ) << 1
   endif
   return temp31..0
endfunction multiplyQ15Q15

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

DPAQX_SA.W.PH

11010

DPA.W.PH

110000

6

5

5

3

2

5

6

Format:

DPAQX_SA.W.PH ac, rs, rt 

MIPSDSP-R2

Cross Dot Product with Accumulation on Fractional Halfword Elements

Purpose:

Cross Dot Product with Accumulation on Fractional Halfword Elements

Element-wise cross multiplication of two vectors of fractional halfword elements and accumulation of the 32-bit intermediate products into the specified 64-bit accumulator register, with saturation of the accumulator.

Description:

ac = sat32(ac + (sat32(rs31..16 * rt15..0) + sat32(rs15..0 * rt31..16)))

The left of the right-most Q15 fractional word values from registers rt is multiplied with the right halfword element from register rs and the result left-shifted by one bit position to generate a Q31 fractional format intermediate product. Similarly, the right of the right-most Q15 fractional word values from registers rt is multiplied with the left halfword element from register rs and the result left-shifted by one bit position to generate a Q31 fractional format intermediate product. If both multiplicands for either of the multiplications are equal to -1.0 (0x8000 hexadecimal), the resulting intermediate product is saturated to the maximum positive Q31 fractional value (0x7FFFFFFF hexadecimal).

The two intermediate products are then sign-extended and summed to generate a 64-bit, Q32.31 fractional format dotproduct result that is accumulated into the specified 64-bit HI/LO accumulator to produce a Q32.31 fractional result. If this result is larger than or equal to +1.0, or smaller than -1.0, it is saturated to the Q31 range.

The value of ac can range from 0 to 3; a value of 0 refers to the original HI/LO register pair of the MIPS64 architecture.

If saturation occurs as a result of halfword multiplication or accumulation, a 1 is written to one of bits 16 through 19 of the DSPControl register, within the ouflag field. The value of ac determines which of these bits is set: bit 16 corresponds to ac0, bit 17 to ac1, bit 18 to ac2, and bit 19 to ac3.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the result is UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB31..0 = multiplyQ15Q15( ac, GPR[rs]31..16, GPR[rt]15..0 )
tempA31..0 = multiplyQ15Q15( ac, GPR[rs]15..0, GPR[rt]31..16 )
dotp63..0 = ( (tempB31)32 || tempB31..0 ) + ( (tempA31)32 || tempA31..0 )
tempC63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) + dotp63..0
if ( tempC63 = 0 ) and ( tempC62..31 != 0 ) then
   tempC63..0 = 032 || 0x7FFFFFFF
   DSPControlouflag:16+acc = 1
endif
if ( tempC63 = 1) and ( tempC62..31 != 132) then
   tempC63..0 = 132 || 0x80000000
   DSPControlouflag:16+acc = 1
endif
( HI[ac]63..0 || LO[ac]63..0 ) = (tempC63)32 || tempC63..32 || (tempC31)32 || tempC31..0
function multiplyQ15Q15( acc1..0, a15..0, b15..0 )
   if ( a15..0 = 0x8000 ) and ( b15..0 = 0x8000 ) then
      temp31..0 = 0x7FFFFFFF
      DSPControlouflag:16+acc = 1
   else
      temp31..0 = ( a15..0 * b15..0 ) << 1
   endif
   return temp31..0
endfunction multiplyQ15Q15

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

DPAQ_S.W.PH

00100

DPA.W.PH

110000

6

5

5

3

2

5

6

Format:

DPAQ_S.W.PH ac, rs, rt 

MIPSDSP

Dot Product with Accumulation on Fractional Halfword Elements

Purpose:

Dot Product with Accumulation on Fractional Halfword Elements

Element-wise multiplication of two vectors of fractional halfword elements and accumulation of the accumulated 32bit intermediate products into the specified 64-bit accumulator register, with saturation.

Description:

ac = ac + (sat32(rs31..16 * rt31..16) + sat32(rs15..0 * rt15..0))

Each of the two right-most Q15 fractional word values from registers rt and rs are multiplied together, and the results left-shifted by one bit position to generate two Q31 fractional format intermediate products. If both multiplicands for either of the multiplications are equal to -1.0 (0x8000 hexadecimal), the resulting intermediate product is saturated to the maximum positive Q31 fractional value (0x7FFFFFFF hexadecimal).

The two intermediate products are then sign-extended and summed to generate a 64-bit, Q32.31 fractional format dotproduct result that is accumulated into the specified 64-bit HI/LO accumulator to produce a final Q32.31 fractional result.

The value of ac can range from 0 to 3; a value of 0 refers to the original HI/LO register pair of the MIPS64 architecture.

If saturation occurs as a result of a halfword multiplication, a 1 is written to one of bits 16 through 19 of the

DSPControl register, within the ouflag field. The value of ac determines which of these bits is set: bit 16 corresponds

to ac0, bit 17 to ac1, bit 18 to ac2, and bit 19 to ac3.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the result is UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB31..0 = multiplyQ15Q15( ac, GPR[rs]31..16, GPR[rt]31..16 )
tempA31..0 = multiplyQ15Q15( ac, GPR[rs]15..0, GPR[rt]15..0 )
dotp63..0 = ( (tempB31)32 || tempB31..0 ) + ( (tempA31)32 || tempA31..0 )
tempC63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) + dotp63..0
( HI[ac]63..0 || LO[ac]63..0 ) = (tempC63)32 || tempC63..32 || (tempC31)32 || tempC31..0
function multiplyQ15Q15( acc1..0, a15..0, b15..0 )
   if ( a15..0 = 0x8000 ) and ( b15..0 = 0x8000 ) then
      temp31..0 = 0x7FFFFFFF
      DSPControlouflag:16+acc = 1
   else
      temp31..0 = ( a15..0 * b15..0 ) << 1
   endif
   return temp31..0
endfunction multiplyQ15Q15

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

DPAQ_SA.L.W

01100

DPA.W.PH

110000

6

5

5

3

2

5

6

Format:

DPAQ_SA.L.W ac, rs, rt 

MIPSDSP

Dot Product with Accumulate on Fractional Word Element

Purpose:

Dot Product with Accumulate on Fractional Word Element

Multiplication of two fractional word elements, accumulating the product to the specified 64-bit accumulator register, with saturation.

Description:

ac = sat64(ac + sat32(rs31..0 * rt31..0))

The two right-most Q31 fractional word values from registers rt and rs are multiplied together and the result leftshifted by one bit position to generate a 64-bit, Q63 fractional format intermediate product. If both multiplicands are equal to -1.0 (0x80000000 hexadecimal), the intermediate product is saturated to the maximum positive Q63 fractional value (0x7FFFFFFFFFFFFFFF hexadecimal).

The intermediate product is then added to the specified 64-bit HI/LO accumulator, creating a Q63 fractional result. If the accumulation results in overflow or underflow, the accumulator is saturated to either the maximum positive or minimum negative Q63 fractional value (0x8000000000000000 hexadecimal), respectively.

The value of ac can range from 0 to 3; a value of 0 refers to the original HI/LO register pair of the MIPS64 architecture.

If saturation occurs, a 1 is written to one of bits 16 through 19 of the DSPControl register, within the ouflag field. The value of ac determines which of these bits is set: bit 16 corresponds to ac0, bit 17 to ac1, bit 18 to ac2, and bit 19 to

ac3.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the result is UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

dotp63..0 = multiplyQ31Q31( ac, GPR[rs]31..0, GPR[rt]31..0 )
temp64..0 = HI[ac]31 || HI[ac]31..0 || LO[ac]31..0
temp64..0 = temp64..0 + dotp63..0
if ( temp64 != temp63 ) then
   if ( temp64 = 1 ) then
      temp63..0 = 0x8000000000000000
   else
      temp63..0 = 0x7FFFFFFFFFFFFFFF
   endif
   DSPControlouflag:16+ac = 1
endif
( HI[ac]63..0 || LO[ac]63..0 ) = (temp63)32 || temp63..32 || (temp31)32 || temp31..0 
function multiplyQ31Q31( acc1..0, a31..0, b31..0 )
   if (( a31..0 = 0x80000000 ) and ( b31..0 = 0x80000000 )) then
      temp63..0 = 0x7FFFFFFFFFFFFFFF
      DSPControlouflag:16+acc = 1
   else
      temp63..0 = ( a31..0 * b31..0 ) << 1
   endif
   return temp63..0
endfunction multiplyQ31Q31

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

DPAU.H.QBL

00011

DPA.W.PH

110000

6

5

5

3

2

5

6

Format:

DPAU.H.QBL ac, rs, rt

MIPSDSP

Dot Product with Accumulate on Vector Unsigned Byte Elements

Purpose:

Dot Product with Accumulate on Vector Unsigned Byte Elements

Element-wise multiplication of the two left-most elements of the four right-most elements of each of two vectors of unsigned bytes, accumulating the sum of the products into the specified 64-bit accumulator register.

Description:

ac = ac + zero_extend((rs31..24 * rt31..24) + (rs23..16 * rt23..16))

The two left-most elements of the four right-most unsigned byte elements of each of registers rt and rs are multiplied together using unsigned arithmetic to generate two 16-bit unsigned intermediate products. The intermediate products are then zero-extended to 64 bits and accumulated into the specified 64-bit HI/LO accumulator.

The value of ac can range from 0 to 3; a value of 0 refers to the original HI/LO register pair of the MIPS64 architecture.

This instruction does not set any bits in the ouflag field in the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the result is UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = multiplyU8U8( GPR[rs]31..24, GPR[rt]31..24 )
tempA15..0 = multiplyU8U8( GPR[rs]23..16, GPR[rt]23..16 )
dotp63..0 = ( 048 || tempB15..0 ) + ( 048 || tempA15..0 )
tempC63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) + dotp63..0
( HI[ac]63..0 || LO[ac]63..0 )  = (tempC63)32 || tempC63..32 || (tempC31)32 || 
tempC31..0 
function multiplyU8U8( a7..0, b7..0 )
   temp17..0 = ( 0 || a7..0 ) * ( 0 || b7..0 )
   return temp15..0
endfunction multiplyU8U8

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

DPAU.H.QBR

00111

DPA.W.PH

110000

6

5

5

3

2

5

6

Format:

DPAU.H.QBR ac, rs, rt

MIPSDSP

Dot Product with Accumulate on Vector Unsigned Byte Elements

Purpose:

Dot Product with Accumulate on Vector Unsigned Byte Elements

Element-wise multiplication of the two right-most elements of the four right-most elements of each of two vectors of unsigned bytes, accumulating the sum of the products into the specified 64-bit accumulator register.

Description:

ac = ac + zero_extend((rs15..8 * rt15..8) + (rs7..0 * rt7..0))

The two right-most elements of the four right-most unsigned byte elements of each of registers rt and rs are multiplied together using unsigned arithmetic to generate two 16-bit unsigned intermediate products. The intermediate products are then zero-extended to 64 bits and accumulated into the specified 64-bit HI/LO accumulator.

The value of ac can range from 0 to 3; a value of 0 refers to the original HI/LO register pair of the MIPS64 architecture.

This instruction does not set any bits in the ouflag field in the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the result is UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = multiplyU8U8( GPR[rs]15..8, GPR[rs]15..8 )
tempA15..0 = multiplyU8U8( GPR[rs]7..0, GPR[rs]7..0 )
dotp63..0 = ( 048 || tempB15..0 ) + ( 048 || tempA15..0 )
tempC63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) + dotp63..0
( HI[ac]63..0 || LO[ac]63..0 ) = (tempC63)32 || tempC63..32 || (tempC31)32 || tempC31..0 

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

00000

ac

DPAX

01000

DPA.W.PH

110000

6

5

5

5

2

5

6

Format:

DPAX.W.PH ac, rs, rt

MIPSDSP-R2

Cross Dot Product with Accumulate on Vector Integer Halfword Elements

Purpose:

Cross Dot Product with Accumulate on Vector Integer Halfword Elements

Generate the cross dot-product of two integer halfword vector elements using full-size intermediate products and then accumulate into the specified accumulator register.

Description:

ac = ac + ((rs31..16 * rt15..0) + (rs15..0 * rt31..16))

The left halfword integer value from register rt is multiplied with the right halfword element from register rs to create an integer word result. Similarly, the right halfword integer value from register rt is multiplied with the left halfword element from register rs to create the second integer word result. These two products are summed to generate the dotproduct result, which is then accumulated into the specified 64-bit HI/LO accumulator, creating a 64-bit integer result.

The value of ac selects an accumulator numbered from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture.

This instruction will not set any bits of the ouflag field in the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the result is UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB31..0 = (GPR[rs]31..16 * GPR[rt]15..0)
tempA31..0 = (GPR[rs]15..0 * GPR[rt]31..16)
dotp32..0 = ( (tempB31) || tempB31..0 ) + ( (tempA31) || tempA31..0 )
acc63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) + ( (dotp32)31 || dotp32..0 )
( HI[ac]63..0 || LO[ac]63..0 ) = (acc63)32 || acc63..32 || (acc31)32 acc31..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

DPS.W.PH

00001

DPA.W.PH

110000

6

5

5

3

2

5

6

Format:

DPS.W.PH ac, rs, rt

MIPSDSP-R2

Dot Product with Subtract on Vector Integer Half-Word Elements

Purpose:

Dot Product with Subtract on Vector Integer Half-Word Elements

Generate the dot-product of two integer halfword vector elements using full-size intermediate products and then subtract from the specified accumulator register.

Description:

ac = ac - ((rs31..16 * rt31..16) + (rs15..0 * rt15..0))

Each of the two halfword integer values from register rt is multiplied with the corresponding halfword element from register rs to create two integer word results. These two products are summed to generate the dot-product result, which is then subtracted from the specified 64-bit HI/LO accumulator, creating a 64-bit integer result.

The value of ac selects an accumulator numbered from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture.

This instruction will not set any bits of the ouflag field in the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the result is UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB31..0 = (GPR[rs]31..16 * GPR[rt]31..16)
tempA31..0 = (GPR[rs]15..0 * GPR[rt]15..0)
dotp32..0 = ( (tempB31) || tempB31..0 ) + ( (tempA31) || tempA31..0 )
acc63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) - ( (dotp32)31 || dotp32..0 )
( HI[ac]63..0 || LO[ac]63..0 ) = (acc63)32 || acc63..32 || (acc31)32 || acc31..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

DPSQX_S.W.PH

11001

DPA.W.PH

110000

6

5

5

3

2

5

6

Format:

DPSQX_S.W.PH ac, rs, rt 

MIPSDSP-R2

Cross Dot Product with Subtraction on Fractional Halfword Elements

Purpose:

Cross Dot Product with Subtraction on Fractional Halfword Elements

Element-wise cross multiplication of two vectors of fractional halfword elements and subtraction of the accumulated

32-bit intermediate products from the specified 64-bit accumulator register, with saturation.

Description:

ac = ac - (sat32(rs31..16 * rt15..0) + sat32(rs15..0 * rt31..16))

The left of the right-most Q15 fractional word values from registers rt is multiplied with the right halfword element from register rs and the result left-shifted by one bit position to generate a Q31 fractional format intermediate product. Similarly, the right of the right-most Q15 fractional word values from registers rt is multiplied with the left halfword element from register rs and the result left-shifted by one bit position to generate a Q31 fractional format intermediate product. If both multiplicands for either of the multiplications are equal to -1.0 (0x8000 hexadecimal), the resulting intermediate product is saturated to the maximum positive Q31 fractional value (0x7FFFFFFF hexadecimal).

The two intermediate products are then sign-extended and summed to generate a 64-bit, Q32.31 fractional format dotproduct result that is subtracted from the specified 64-bit HI/LO accumulator to produce a final Q32.31 fractional result.

The value of ac can range from 0 to 3; a value of 0 refers to the original HI/LO register pair of the MIPS64 architecture.

If saturation occurs as a result of a halfword multiplication, a 1 is written to one of bits 16 through 19 of the

DSPControl register, within the ouflag field. The value of ac determines which of these bits is set: bit 16 corresponds

to ac0, bit 17 to ac1, bit 18 to ac2, and bit 19 to ac3.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the result is UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB31..0 = multiplyQ15Q15( ac, GPR[rs]31..16, GPR[rt]15..0 )
tempA31..0 = multiplyQ15Q15( ac, GPR[rs]15..0, GPR[rt]31..16 )
dotp63..0 = ( (tempB31)32 || tempB31..0 ) + ( (tempA31)32 || tempA31..0 )
tempC63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) - dotp63..0
( HI[ac]63..0 || LO[ac]63..0 ) = (tempC63)32 || tempC63..32 || (tempC31)32 || tempC31..0
function multiplyQ15Q15( acc1..0, a15..0, b15..0 )
   if ( a15..0 = 0x8000 ) and ( b15..0 = 0x8000 ) then
      temp31..0 = 0x7FFFFFFF
      DSPControlouflag:16+acc = 1
   else
      temp31..0 = ( a15..0 * b15..0 ) << 1
   endif
   return temp31..0
endfunction multiplyQ15Q15

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

DPSQX_SA.W.PH

11011

DPA.W.PH

110000

6

5

5

3

2

5

6

Format:

DPSQX_SA.W.PH ac, rs, rt 

MIPSDSP-R2

Cross Dot Product with Subtraction on Fractional Halfword Elements

Purpose:

Cross Dot Product with Subtraction on Fractional Halfword Elements

Element-wise cross multiplication of two vectors of fractional halfword elements and subtraction of the accumulated

32-bit intermediate products from the specified 64-bit accumulator register, with saturation of the accumulator.

Description:

ac = sat32(ac - (sat32(rs31..16 * rt15..0) + sat32(rs15..0 * rt31..16)))

The left of the right-most Q15 fractional word values from registers rt is multiplied with the right halfword element from register rs and the result left-shifted by one bit position to generate a Q31 fractional format intermediate product. Similarly, the right of the right-most Q15 fractional word values from registers rt is multiplied with the left halfword element from register rs and the result left-shifted by one bit position to generate a Q31 fractional format intermediate product. If both multiplicands for either of the multiplications are equal to -1.0 (0x8000 hexadecimal), the resulting intermediate product is saturated to the maximum positive Q31 fractional value (0x7FFFFFFF hexadecimal).

The two intermediate products are then sign-extended and summed to generate a 64-bit, Q32.31 fractional format dotproduct result that is subtracted from the specified 64-bit HI/LO accumulator to produce a Q32.31 fractional result. If this result is larger than or equal to +1.0, or smaller than -1.0, it is saturated to the Q31 range.

The value of ac can range from 0 to 3; a value of 0 refers to the original HI/LO register pair of the MIPS64 architecture.

If saturation occurs as a result of halfword multiplication or accumulation, a 1 is written to one of bits 16 through 19 of the DSPControl register, within the ouflag field. The value of ac determines which of these bits is set: bit 16 corresponds to ac0, bit 17 to ac1, bit 18 to ac2, and bit 19 to ac3.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the result is UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB31..0 = multiplyQ15Q15( ac, GPR[rs]31..16, GPR[rt]15..0 )
tempA31..0 = multiplyQ15Q15( ac, GPR[rs]15..0, GPR[rt]31..16 )
dotp63..0 = ( (tempB31)32 || tempB31..0 ) + ( (tempA31)32 || tempA31..0 )
tempC63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) - dotp63..0
if ( tempC63 = 0 ) and ( tempC62..31 != 0 ) then
   tempC63..0 = 032 || 0x7FFFFFFF
   DSPControlouflag:16+acc = 1
endif
if ( tempC63 = 1) and ( tempC62..31 != 132) then
   tempC63..0 = 132 || 0x80000000
   DSPControlouflag:16+acc = 1
endif
( HI[ac]63..0 || LO[ac]63..0 ) = (tempC63)32 || tempC63..32 || (tempC31)32 || tempC31..0
function multiplyQ15Q15( acc1..0, a15..0, b15..0 )
   if ( a15..0 = 0x8000 ) and ( b15..0 = 0x8000 ) then
      temp31..0 = 0x7FFFFFFF
      DSPControlouflag:16+acc = 1
   else
      temp31..0 = ( a15..0 * b15..0 ) << 1
   endif
   return temp31..0
endfunction multiplyQ15Q15

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

DPSQ_S.W.PH

00101

DPA.W.PH

110000

6

5

5

3

2

5

6

Format:

DPSQ_S.W.PH ac, rs, rt 

MIPSDSP

Dot Product with Subtraction on Fractional Halfword Elements

Purpose:

Dot Product with Subtraction on Fractional Halfword Elements

Element-wise multiplication of two vectors of fractional halfword elements and subtraction of the accumulated 32-bit intermediate products from the specified 64-bit accumulator register, with saturation.

Description:

ac = ac - (sat32(rs31..16 * rt31..16) + sat32(rs15..0 * rt15..0))

Each of the two right-most Q15 fractional word values from registers rt and rs are multiplied together, and the results left-shifted by one bit position to generate two Q31 fractional format intermediate products. If both multiplicands for either of the multiplications are equal to -1.0 (0x8000 hexadecimal), the resulting intermediate product is saturated to the maximum positive Q31 fractional value (0x7FFFFFFF hexadecimal).

The two intermediate products are then sign-extended and summed to generate a 64-bit, Q32.31 fractional format dotproduct result that is subtracted from the specified 64-bit HI/LO accumulator to produce a final Q32.31 fractional result.

The value of ac can range from 0 to 3; a value of 0 refers to the original HI/LO register pair of the MIPS64 architecture.

If saturation occurs as a result of a halfword multiplication, a 1 is written to one of bits 16 through 19 of the

DSPControl register, within the ouflag field. The value of ac determines which of these bits is set: bit 16 corresponds

to ac0, bit 17 to ac1, bit 18 to ac2, and bit 19 to ac3.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the result is UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB31..0 = multiplyQ15Q15( ac, GPR[rs]31..16, GPR[rt]31..16 )
tempA31..0 = multiplyQ15Q15( ac, GPR[rs]15..0, GPR[rt]15..0 )
dotp63..0 = ( (tempB31)32 || tempB31..0 ) + ( (tempA31)32 || tempA31..0 )
tempC63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) - dotp63..0
( HI[ac]63..0 || LO[ac]63..0 )  = (tempC63)32 || tempC63..32 || (tempC31)32 || 
tempC31..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

DPSQ_SA.L.W

01101

DPA.W.PH

110000

6

5

5

3

2

5

6

Format:

DPSQ_SA.L.W ac, rs, rt 

MIPSDSP

Dot Product with Subtraction on Fractional Word Element

Purpose:

Dot Product with Subtraction on Fractional Word Element

Multiplication of two fractional word elements, subtracting the accumulated product from the specified 64-bit accumulator register, with saturation.

Description:

ac = sat64(ac - sat32(rs31..0 * rt31..0))

The two right-most Q31 fractional word values from registers rt and rs are multiplied together and the result leftshifted by one bit position to generate a 64-bit Q63 fractional format intermediate product. If both multiplicands are equal to -1.0 (0x80000000 hexadecimal), the intermediate product is saturated to the maximum positive Q63 fractional value (0x7FFFFFFFFFFFFFFF hexadecimal).

The intermediate product is then subtracted from the specified 64-bit HI/LO accumulator, creating a Q63 fractional result. If the accumulation results in overflow or underflow, the accumulator is saturated to either the maximum positive or minimum negative Q63 fractional value (0x8000000000000000 hexadecimal), respectively.

The value of ac can range from 0 to 3; a value of 0 refers to the original HI/LO register pair of the MIPS64 architecture.

If saturation occurs, a 1 is written to one of bits 16 through 19 of the DSPControl register, within the ouflag field. The value of ac determines which of these bits is set: bit 16 corresponds to ac0, bit 17 to ac1, bit 18 to ac2, and bit 19 to

ac3.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the result is UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

dotp63..0 = multiplyQ31Q31( ac, GPR[rs]31..0, GPR[rt]31..0 )
temp64..0 = HI[ac]31 || HI[ac]31..0 || LO[ac]31..0
temp64..0 = temp - dotp63..0
if ( temp64 != temp63 ) then
   if ( temp64 = 1 ) then
      temp63..0 = 0x8000000000000000
   else
      temp63..0 = 0x7FFFFFFFFFFFFFFF
   endif
   DSPControlouflag:16+ac = 1
endif
( HI[ac]63..0 || LO[ac]63..0 )  = (temp63)32 || temp63..32 || (temp31)32 || temp31..0 

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

DPSU.H.QBL

01011

DPA.W.PH

110000

6

5

5

3

2

5

6

Format:

DPSU.H.QBL ac, rs, rt

MIPSDSP

Dot Product with Subtraction on Vector Unsigned Byte Elements

Purpose:

Dot Product with Subtraction on Vector Unsigned Byte Elements

Element-wise multiplication of two left-most elements from the four right-most elements of each of two vectors of unsigned bytes, subtracting the sum of the products from the specified 64-bit accumulator register.

Description:

ac = ac - zero_extend((rs31..24 * rt31..24) + (rs23..16 * rt23..16))

The two left-most elements of the four right-most unsigned byte elements of each of registers rt and rs are multiplied together using unsigned arithmetic to generate two 16-bit unsigned intermediate products. The intermediate products are then zero-extended to 64 bits and subtracted from the specified 64-bit HI/LO accumulator. The result of the subtraction is written back to the specified 64-bit HI/LO accumulator.

The value of ac can range from 0 to 3; a value of 0 refers to the original HI/LO register pair of the MIPS64 architecture.

This instruction does not set any bits in the ouflag field in the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the result is UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = multiplyU8U8( GPR[rs]31..24, GPR[rt]31..24 )
tempA15..0 = multiplyU8U8( GPR[rs]23..16, GPR[rt]23..16 )
dotp63..0 = ( 048 || tempB15..0 ) + ( 048 || tempA15..0 )
tempC63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) - dotp63..0
( HI[ac]63..0 || LO[ac]63..0 ) = (tempC63)32 || tempC63..32 || (tempC31)32 || tempC31..0 

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

DPSU.H.QBR

01111

DPA.W.PH

110000

6

5

5

3

2

5

6

Format:

DPSU.H.QBR ac, rs, rt

MIPSDSP

Dot Product with Subtraction on Vector Unsigned Byte Elements

Purpose:

Dot Product with Subtraction on Vector Unsigned Byte Elements

Element-wise multiplication of the two right-most elements of the four right-most elements of each of two vectors of unsigned bytes, subtracting the sum of the products from the specified 64-bit accumulator register.

Description:

ac = ac - zero_extend((rs15..8 * rt15..8) + (rs7..0 * rt7..0))

The two right-most elements of the four right-most unsigned byte elements of each of registers rt and rs are multiplied together using unsigned arithmetic to generate two 16-bit unsigned intermediate products. The intermediate products are then zero-extended to 64 bits and subtracted from the specified 64-bit HI/LO accumulator.

The value of ac can range from 0 to 3; a value of 0 refers to the original HI/LO register pair of the MIPS64 architecture.

This instruction does not set any bits in the ouflag field in the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the result is UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = multiplyU8U8( GPR[rs]15..8, GPR[rt]15..8 )
tempA15..0 = multiplyU8U8( GPR[rs]7..0, GPR[rt]7..0 )
dotp63..0 = ( 048 || tempB15..0 ) + ( 048 || tempA15..0 )
tempC63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) - dotp63..0
( HI[ac]63..0 || LO[ac]63..0 ) = (tempC63)32 || tempC63..32 || (tempC31)32 || tempC31..0 

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

00000

ac

DPSX

01001

DPA.W.PH

110000

6

5

5

5

2

5

6

Format:

DPSX.W.PH ac, rs, rt

MIPSDSP-R2

Cross Dot Product with Subtract on Vector Integer Halfword Elements

Purpose:

Cross Dot Product with Subtract on Vector Integer Halfword Elements

Generate the cross dot-product of two integer halfword vector elements using full-size intermediate products and then subtract from the specified accumulator register.

Description:

ac = ac - ((rs31..16 * rt15..0) + (rs15..0 * rt31..16))

The left halfword integer value from register rt is multiplied with the right halfword element from register rs to create an integer word result. Similarly, the right halfword integer value from register rt is multiplied with the left halfword element from register rs to create the second integer word result. These two products are summed to generate the dotproduct result, which is then subtracted from the specified 64-bit HI/LO accumulator, creating a 64-bit integer result.

The value of ac selects an accumulator numbered from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture.

This instruction will not set any bits of the ouflag field in the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the result is UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB31..0 = (GPR[rs]31..16 * GPR[rt]15..0)
tempA31..0 = (GPR[rs]15..0 * GPR[rt]31..16)
dotp32..0 = ( (tempB31) || tempB31..0 ) + ( (tempA31) || tempA31..0 )
acc63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) - ( (dotp32)31 || dotp32..0 )
( HI[ac]63..0 || LO[ac]63..0 ) = (acc63)32 || acc63..32 || (acc31)32 acc31..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

size

rt

0

000

ac

EXTPDP

01010

EXTR.W

111000

6

5

5

3

2

5

6

Format:

EXTPDP rt, ac, size

MIPSDSP

Extract Fixed Bitfield From Arbitrary Position in Accumulator to GPR and Decrement Pos

Purpose:

Extract Fixed Bitfield From Arbitrary Position in Accumulator to GPR and Decrement Pos

Extract size+1 contiguous bits from a 64-bit accumulator from a position specified in the DSPControl register, writing the bits to a GPR with zero-extension and modifying the extraction position.

Description:

rt = zero_extend(acpos..pos-size) ; DSPControlpos:6..0 -= (size+1)

A set of size+1 contiguous bits are extracted from an arbitrary position in accumulator ac, zero-extended to 64 bits, then written to register rt.

The bit position, start_pos, of the first bit of the contiguous set to extract is specified by the pos field in bits 0 through

5 of the DSPControl register; bit 6 of the DSPControl register is ignored. The position of the last bit in the extracted set is start_pos - size, where the size argument is specified in the instruction.

The value of ac can range from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture. After the execution of this instruction, accumulator ac remains unmodified.

If , the extraction is valid and the value of the pos field in the DSPControl register is decrestart_pos

-size1+1->=( ) mented by size+1. Otherwise, the extraction is invalid and is said to have failed. The value of the destination register is UNPREDICTABLE when the extraction is invalid, and the value of the pos field in the DSPControl register (bits

0 through 6) is not modified.

Upon an invalid extraction this instruction writes a 1 to bit 14, the Extract Failed Indicator (EFI) bit of the

DSPControl register, and 0 otherwise.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

start_pos5..0 = DSPControlpos:5..0
if ( start_pos - (size+1) >= -1 ) then
   tempsize..0 = ( HI[ac]31..0 || LO[ac]31..0 )start_pos..start_pos-size
   GPR[rt] = 0(GPRLEN-(size+1)) || tempsize..0
   DSPControlpos:6..0 = DSPControlpos:6..0 - (size + 1)
   DSPControlEFI:14 = 0
else
   DSPControlEFI:14 = 1
   GPR[rt] = UNPREDICTABLE
endif

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

EXTPDPV

01011

EXTR.W

111000

6

5

5

3

2

5

6

Format:

EXTPDPV rt, ac, rs

MIPSDSP

Extract Variable Bitfield From Arbitrary Position in Accumulator to GPR and Decrement Pos

Purpose:

Extract Variable Bitfield From Arbitrary Position in Accumulator to GPR and Decrement Pos

Extract a fixed number of contiguous bits from a 64-bit accumulator from a position specified in the DSPControl register, writing the bits to a GPR with zero-extension and modifying the extraction position.

Description:

rt = zero_extend(acpos..pos-GPR[rs][4:0]) ; DSPControlpos:6..0 -= (GPR[rs]4..0+1)

A fixed number of contiguous bits are extracted from an arbitrary position in accumulator ac, zero-extended to 64 bits, then written to destination register rt. The number of bits extracted is size+1, where size is specified by the five least-significant bits in register rs, interpreted as a five-bit unsigned integer. The remaining bits in register rs are ignored.

The bit position, start_pos, of the first bit of the contiguous set to extract is specified by the pos field in bits 0 through

5 of the DSPControl register; bit 6 of the DSPControl register is ignored. The position of the last bit in the extracted set is start_pos - size.

The value of ac can range from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture. After the execution of this instruction, accumulator ac remains unmodified.

If , the extraction is valid and the value of the pos field in the DSPControl register is decrestart_pos

-size1+1->=( ) mented by size+1. Otherwise, the extraction is invalid and is said to have failed. The value of the destination register is UNPREDICTABLE when the extraction is invalid, and the value of the pos field in the DSPControl register (bits

0 through 6) is not modified.

Upon an invalid extraction this instruction writes a 1 to bit 14, the Extract Failed Indicator (EFI) bit of the

DSPControl register, and 0 otherwise.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

start_pos5..0 = DSPControlpos:5..0
size4..0 = GPR[rs]4..0
if ( start_pos - (size+1) >= -1 ) then
   tempsize..0 = ( HI[ac]31..0 || LO[ac]31..0 )start_pos..start_pos-size
   GPR[rt] = 0(GPRLEN-(size+1)) || tempsize..0
   DSPControlpos:6..0 = DSPControlpos:6..0 - (size + 1)
   DSPControlEFI:14 = 0
else
   DSPControlEFI:14 = 1
   GPR[rt] = UNPREDICTABLE
endif

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

size

rt

0

000

ac

EXTP

00010

EXTR.W

111000

6

5

5

3

2

5

6

Format:

EXTP rt, ac, size

MIPSDSP

Extract Fixed Bitfield From Arbitrary Position in Accumulator to GPR

Purpose:

Extract Fixed Bitfield From Arbitrary Position in Accumulator to GPR

Extract size+1 contiguous bits from a 64-bit accumulator from a position specified in the DSPControl register, writing the bits to a GPR with zero-extension.

Description:

rt = sign_extend(zero_extend(acpos..pos-size))

A set of size+1 contiguous bits are extracted from an arbitrary position in accumulator ac, zero-extended to 64 bits, and then written to register rt.

The bit position, start_pos, of the first bit of the contiguous set to extract is specified by the pos field in bits 0 through

5 of the DSPControl register; bit 6 of the DSPControl register is ignored. The last bit in the set is start_pos - size, where size is specified in the instruction.

The value of ac can range from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture. After the execution of this instruction, accumulator ac remains unmodified.

If , the extraction is valid, otherwise the extraction is invalid and is said to have failed. Thestart_pos

-size1+1->=( ) value of the destination register is UNPREDICTABLE when the extraction is invalid. Upon an invalid extraction this instruction writes a 1 to bit 14, the Extract Failed Indicator (EFI) bit of the DSPControl register, and 0 otherwise.

Bit 31 of the result is extended into the 32 most-significant bits of the destination register.

The values of bits 0 to 6 in the pos field of the DSPControl register are unchanged by this instruction.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

start_pos5..0 = DSPControlpos:5..0
if ( start_pos - (size+1) >= -1 ) then
   tempsize..0 = ( HI[ac]31..0 || LO[ac]31..0 )start_pos..start_pos-size
   temp31..0 = 0(32-(size+1)) || tempsize..0
   GPR[rt]63..0 = (temp31)32 || temp31..0
   DSPControlEFI:14 = 0
else
   DSPControlEFI:14 = 1
   GPR[rt] = UNPREDICTABLE
endif

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

EXTPV

00011

EXTR.W

111000

6

5

5

3

2

5

6

Format:

EXTPV rt, ac, rs

MIPSDSP

Extract Variable Bitfield From Arbitrary Position in Accumulator to GPR

Purpose:

Extract Variable Bitfield From Arbitrary Position in Accumulator to GPR

Extract a variable number of contiguous bits from a 64-bit accumulator from a position specified in the DSPControl register, writing the bits to a GPR with zero-extension.

Description:

rt = zero_extend(acpos..pos-rs[4:0])

A variable number of contiguous bits are extracted from an arbitrary position in accumulator ac, zero-extended to 64 bits, then written to register rt. The number of bits extracted is size+1, where size is specified by the five least-significant bits in register rs, interpreted as a five-bit unsigned integer. The remaining bits in register rs are ignored.

The position of the first bit of the contiguous set to extract, start_pos, is specified by the pos field in bits 0 through 6 of the DSPControl register. The position of the last bit in the contiguous set is start_pos - size.

The value of ac can range from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture. After the execution of this instruction, accumulator ac remains unmodified.

An extraction is valid if ; otherwise, the extraction is invalid and is said to have failed. Thestart_pos

-size1+1->=( ) value of the destination register is UNPREDICTABLE when the extraction is invalid. Upon an invalid extraction this instruction writes a 1 to bit 14, the Extract Failed Indicator (EFI) bit of the DSPControl register, and 0 otherwise.

The values of bits 0 to 6 in the pos field of the DSPControl register are unchanged by this instruction.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

start_pos5..0 = DSPControlpos:5..0
size4..0 = GPR[rs]4..0
if ( start_pos - (size+1) >= -1 ) then
   tempsize..0 = ( HI[ac]31..0 || LO[ac]31..0 )start_pos..start_pos-size
   GPR[rt] = 0(GPRLEN-(size+1)) || tempsize..0
   DSPControlEFI:14 = 0
else
   DSPControlEFI:14 = 1
   GPR[rt] = UNPREDICTABLE
endif

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

EXTRV.W

00001

EXTR.W

111000

SPECIAL3

011111

rs

rt

0

000

ac

EXTRV_R.W

00101

EXTR.W

111000

SPECIAL3

011111

rs

rt

0

000

ac

EXTRV_RS.W

00111

EXTR.W

111000

6

5

5

3

2

5

6

Format:

EXTRV[_RS].W 

Extract Word Value With Variable Right Shift From Accumulator to GPR

EXTRV.W   rt, ac, rs

MIPSDSP

Extract Word Value With Variable Right Shift From Accumulator to GPR

EXTRV_R.W rt, ac, rs

MIPSDSP

Extract Word Value With Variable Right Shift From Accumulator to GPR

EXTRV_RS.W rt, ac, rs

MIPSDSP

Extract Word Value With Variable Right Shift From Accumulator to GPR

Purpose:

Extract Word Value With Variable Right Shift From Accumulator to GPR

Extract a word value from a 64-bit accumulator to a GPR with variable right shift, and with optional rounding or rounding and saturation.

Description:

rt = sign_extend(sat32(round(ac >> rs5..0)))

The value in accumulator ac is shifted right by shift bits with sign extension (arithmetic shift right). The lower 32 bits of the shifted value are then sign extended to 64-bits and written to the destination register rt. The number of bits to shift is given by the five least-significant bits of register rs; the remaining bits of rs are ignored.

The rounding variant of the instruction adds a 1 at the most-significant discarded bit position. The 32 least-significant bits of the rounded result are then sign extended to 64-bits and written to the destination register.

The rounding and saturating variant of the instruction adds a 1 at the most-significant discarded bit position. If the rounding operation results in an overflow, the shifted value is clamped to the maximum positive Q31 fractional value

(0x7FFFFFFF hexadecimal). The rounded and saturated result is then sign extended to 64-bits and written to the destination register.

The value of ac can range from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture. After the execution of this instruction, ac remains unmodified.

For all variants of the instruction, including EXTRV.W, bit 23 of the DSPControl register is set to 1 if either of the rounded or non-rounded calculation results in overflow or saturation.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

EXTRV.W:
   temp64..0 = _shiftShortAccRightArithmetic( ac, GPR[rs]4..0 )
   if (( temp64..32 != 0 ) and ( temp64..32 != 0x1FFFFFFFF )) then
      DSPControlouflag:23 = 1
   endif
   GPR[rt]63..0 = (temp32)32 || temp32..1
   temp64..0 = temp + 1
   if (( temp64..32 != 0 ) and ( temp64..32 != 0x1FFFFFFFF )) then
      DSPControlouflag:23 = 1
   endif
EXTRV_R.W:
   temp64..0 = _shiftShortAccRightArithmetic( ac, GPR[rs]4..0 )
   if (( temp64..32 != 0 ) and ( temp64..32 != 0x1FFFFFFFF )) then
      DSPControlouflag:23 = 1
   endif
   temp64..0 = temp + 1
   if (( temp64..32 != 0 ) and ( temp64..32 != 0x1FFFFFFFF )) then
      DSPControlouflag:23 = 1
   endif
   GPR[rt]63..0 = (temp32)32 || temp32..1
EXTRV_RS.W:
   temp64..0 = _shiftShortAccRightArithmetic( ac, GPR[rs]4..0 )
   if (( temp64..32 != 0 ) and ( temp64..32 != 0x1FFFFFFFF )) then
      DSPControlouflag:23 = 1
   endif
   temp64..0 = temp + 1
   if (( temp64..32 != 0 ) and ( temp64..32 != 0x1FFFFFFFF )) then
      if ( temp64 = 0 ) then
          temp32..1 = 0x7FFFFFFF
      else
          temp32..1 = 0x80000000
      endif
      DSPControlouflag:23 = 1
   endif
   GPR[rt]63..0 = (temp32)32 || temp32..1

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

EXTRV_S.H

01111

EXTR.W

111000

6

5

5

3

2

5

6

Format:

EXTRV_S.H rt, ac, rs

MIPSDSP

Extract Halfword Value Variable From Accumulator to GPR With Right Shift and Saturate

Purpose:

Extract Halfword Value Variable From Accumulator to GPR With Right Shift and Saturate

Extract a halfword value from a 64-bit accumulator to a GPR with right shift and saturation.

Description:

rt = sign_extend(sat16(ac >> rs4..0))

The value in the 64-bit accumulator ac is shifted right by shift bits with sign extension (arithmetic shift right). The 64bit value is then saturated to 16-bits and sign-extended to 64 bits before being written to the destination register rt.

The five least-significant bits of register rs provide the shift argument, interpreted as a five-bit unsigned integer; the remaining bits in rs are ignored.

The value of ac can range from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture. After the execution of this instruction, ac remains unmodified.

This instruction sets bit 23 of the DSPControl register in the ouflag field if the operation results in saturation.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

shift4..0 = GPR[rs]4..0
temp31..0 = shiftShortAccRightArithmetic( ac, shift )
if ( temp63..0 > 0x0000000000007FFF ) then
   temp31..0 = 0x00007FFF
   DSPControl23 = 1
else if ( temp63..0 < 0xFFFFFFFFFFFF8000 ) then
   temp31..0 = 0xFFFF8000
   DSPControl23 = 1
endif
GPR[rt]63..0 = (temp31)32 || temp31..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

shift

rt

0

000

ac

EXTR.W

00000

EXTR.W

111000

SPECIAL3

011111

shift

rt

0

000

ac

EXTR_R.W

00100

EXTR.W

111000

SPECIAL3

011111

shift

rt

0

000

ac

EXTR_RS.W

00110

EXTR.W

111000

6

5

5

3

2

5

6

Format:

EXTR[_RS].W 

Extract Word Value With Right Shift From Accumulator to GPR

EXTR.W   rt, ac, shift

MIPSDSP

Extract Word Value With Right Shift From Accumulator to GPR

EXTR_R.W  rt, ac, shift

MIPSDSP

Extract Word Value With Right Shift From Accumulator to GPR

EXTR_RS.W rt, ac, shift

MIPSDSP

Extract Word Value With Right Shift From Accumulator to GPR

Purpose:

Extract Word Value With Right Shift From Accumulator to GPR

Extract a word value from a 64-bit accumulator to a GPR with right shift, and with optional rounding or rounding and saturation.

Description:

rt = sign_extend(sat32(round(ac >> shift)))

The value in accumulator ac is shifted right by shift bits with sign extension (arithmetic shift right). The 32 least-significant bits of the shifted value are then sign extended to 64 bits and written to the destination register rt.

The rounding variant of the instruction adds a 1 at the most-significant discarded bit position. The 32 least-significant bits of the rounded result are then sign-extended to 64 bits and written to the destination register.

The rounding and saturating variant of the instruction adds a 1 at the most-significant discarded bit position. If the rounding operation results in an overflow, the shifted value is clamped to the maximum positive Q31 fractional value

(0x7FFFFFFF hexadecimal). The rounded and saturated result is then sign-extended to 64 bits and written to the destination register.

The value of ac can range from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture. After the execution of this instruction, ac remains unmodified.

For all variants of the instruction, including EXTR.W, bit 23 of the DSPControl register is set to 1 if either of the rounded or non-rounded calculation results in overflow or saturation.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

EXTR.W:
temp64..0 = _shiftShortAccRightArithmetic( ac, shift )
   if (( temp64..32 != 0 ) and ( temp64..32 != 0x1FFFFFFFF ) ) then
      DSPControlouflag:23 = 1
   endif
   GPR[rt]63..0 = (temp32)32 || temp32..1
   temp64..0 = temp + 1
   if (( temp64..32 != 0 ) and ( temp64..32 != 0x1FFFFFFFF )) then
      DSPControlouflag:23 = 1
   endif
EXTR_R.W:
   temp64..0 = _shiftShortAccRightArithmetic( ac, shift )
   if (( temp64..32 != 0 ) and ( temp64..32 != 0x1FFFFFFFF )) then
      DSPControlouflag:23 = 1
   endif
   temp64..0 = temp + 1
   if (( temp64..32 != 0 ) and ( temp64..32 != 0x1FFFFFFFF )) then
      DSPControlouflag:23 = 1
   endif
   GPR[rt]63..0 = (temp32)32 || temp32..1
EXTR_RS.W:
   temp64..0 = _shiftShortAccRightArithmetic( ac, shift )
   if (( temp64..32 != 0 ) and ( temp64..32 != 0x1FFFFFFFF )) then
      DSPControlouflag:23 = 1
   endif
   temp64..0 = temp + 1
   if (( temp64..32 != 0 ) and ( temp64..32 != 0x1FFFFFFFF )) then
      if ( temp64 = 0 ) then
          temp32..1 = 0x7FFFFFFF
      else
          temp32..1 = 0x80000000
      endif
      DSPControlouflag:23 = 1
   endif
   GPR[rt]63..0 = (temp32)32 || temp32..1
function _shiftShortAccRightArithmetic( ac1..0, shift4..0 )
   if ( shift4..0 = 0 ) then
      temp64..0 = ( HI[ac]31..0 || LO[ac]31..0 || 0 )
   else
      temp64..0 = ( (HI[ac]31)shift || HI[ac]31..0 || LO[ac]31..shift-1 )
   endif
   return temp64..0
endfunction _shiftShortAccRightArithmetic

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

shift

rt

0

000

ac

EXTR_S.H

01110

EXTR.W

111000

6

5

5

3

2

5

6

Format:

EXTR_S.H rt, ac, shift

MIPSDSP

Extract Halfword Value From Accumulator to GPR With Right Shift and Saturate

Purpose:

Extract Halfword Value From Accumulator to GPR With Right Shift and Saturate

Extract a halfword value from a 64-bit accumulator to a GPR with right shift and saturation.

Description:

rt = sign_extend(sat16(ac >> shift))

The value in the 64-bit accumulator ac is shifted right by shift bits with sign extension (arithmetic shift right). The 64bit value is then saturated to 16-bits, sign extended to 64 bits, and written to the destination register rt. The shift argument is provided in the instruction.

The value of ac can range from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture. After the execution of this instruction, ac remains unmodified.

This instruction sets bit 23 of the DSPControl register in the ouflag field if the operation results in saturation.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

temp63..0 = shiftShortAccRightArithmetic( ac, shift )
if ( temp63..0 > 0x0000000000007FFF ) then
   temp31..0 = 0x00007FFF
   DSPControlouflag:23 = 1
else if ( temp63..0 < 0xFFFFFFFFFFFF8000 ) then
   temp31..0 = 0xFFFF8000
   DSPControlouflag:23 = 1
endif
GPR[rt]63..0 = (temp31)32 || temp31..0
function shiftShortAccRightArithmetic( ac1..0, shift4..0 )
   sign = HI[ac]31
   if ( shift = 0 ) then
      temp63..0 = HI[ac]31..0 || LO[ac]31..0
   else
      temp63..0 = signshift || (( HI[ac]31..0 || LO[ac]31..0 ) >> shift )
   endif
   if ( sign != temp31 ) then
      DSPControlouflag:23 = 1
   endif
   return temp63..0
endfunction shiftShortAccRightArithmetic

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

00000

0

00000

INSV

001100

6

5

5

5

5

6

Format:

INSV rt, rs

MIPSDSP

Insert Bit Field Variable

Purpose:

Insert Bit Field Variable

To merge a right-justified bit field from register rs into a specified field in register rt.

Description:

rt = InsertFieldVar(rt, rs, Scount, Pos)

The DSPControl register provides the size value from the Scount field, and the pos value from the pos field. The rightmost size bits from register rs are merged into the value from register rt starting at bit position pos. The result is put back in register rt. These pos and size values are converted by the instruction into the fields msb (the most significant bit of the field), and lsb (least significant bit of the field), as follows:

pos = DSPControl5..0
size = DSPControl12..7
msb = pos+size-1
lsb = pos

The values of pos and size must satisfy all of the following relations, or the instruction results in UNPREDICTABLE results:

0 <= pos < 32
0 < size <= 32
0 < pos+size <= 32

Restrictions:

The operation is UNPREDICTABLE if lsb > msb.

If either register rs or register rt does not contain sign-extended 32-bit values (bits 63..31 equal), then the result of the operation is UNPREDICTABLE.

Operation:

if (lsb > msb) or (NotWordValue(GPR[rs])) or (NotWordValue(GPR[rt]))) then
   UNPREDICTABLE
endif
GPR[rt]63..0 = (GPR[rt]31)32 || GPR[rt]31..msb+1 || GPR[rs]msb-lsb..0 || GPR[rt]lsb-1..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

base

index

rd

LBUX

00110

LX

001010

6

5

5

5

5

6

Format:

LBUX rd, index(base)

MIPSDSP

Load Unsigned Byte Indexed

Purpose:

Load Unsigned Byte Indexed

To load a byte from memory as an unsigned value, using indexed addressing.

Description:

 rd = memory[base+index]

The contents of GPR index is added to the contents of GPR base to form an effective address. The contents of the 8bit byte at the memory location specified by the aligned effective address are fetched, zero-extended to the GPR register length and placed in GPR rd.

Restrictions:

None.

Operation:

vAddr31..0 = GPR[index]31..0 + GPR[base]31..0
( pAddr, CCA ) = AddressTranslation( vAddr, DATA, LOAD )
pAddr = pAddrPSIZE-1..2 || ( pAddr1..0 xor ReverseEndian2 )
memwordGPRLEN..0 = LoadMemory ( CCA, BYTE, pAddr, vAddr, DATA )
GPR[rd]63..0 = zero_extend( memword7..0 )

Exceptions:

Reserved Instruction, DSP Disabled, TLB Refill, TLB Invalid, Bus Error, Address Error, Watch

Encoding:

SPECIAL3

011111

base

index

rd

LDX

01000

LX

001010

6

5

5

5

5

6

Format:

LDX rd, index(base)

MIPSDSP

Load Doubleword Indexed

Purpose:

Load Doubleword Indexed

To load a doubleword value from memory as a signed value, using indexed addressing.

Description:

 rd = memory[base+index]

The contents of GPR index is added to the contents of GPR base to form an effective address. The contents of the 64bit word at the memory location specified by the aligned effective address are fetched and placed in GPR rd.

Restrictions:

The effective address must be naturally-aligned. If any of the three least-significant bits of the address are non-zero, an Address Error exception occurs.

Operation:

vAddr63..0 = GPR[index] + GPR[base]
if ( vAddr2..0 != 03 ) then
   SignalException( AddressError )
endif
( pAddr, CCA ) = AddressTranslation( vAddr, DATA, LOAD )
doubleword63..0 = LoadMemory ( CCA, DOUBLEWORD, pAddr, vAddr, DATA )
GPR[rd]63..0 = doubleword63..0

Exceptions:

Reserved Instruction, DSP Disabled, TLB Refill, TLB Invalid, Bus Error, Address Error, Watch

Encoding:

SPECIAL3

011111

base

index

rd

LHX

00100

LX

001010

6

5

5

5

5

6

Format:

LHX rd, index(base)

MIPSDSP

Load Halfword Indexed

Purpose:

Load Halfword Indexed

To load a halfword value from memory as a signed value, using indexed addressing.

Description:

 rd = memory[base+index]

The contents of GPR index is added to the contents of GPR base to form an effective address. The contents of the 16bit halfword at the memory location specified by the aligned effective address are fetched, sign-extended to the length of the destination GPR, and placed in GPR rd.

Restrictions:

The effective address must be naturally-aligned. If the least-significant bit of the effective address is non-zero, an

Address Error exception occurs.

Operation:

vAddr31..0 = GPR[index]31..0 + GPR[base]31..0
if ( vAddr0 != 0 ) then
   SignalException( AddressError )
endif
( pAddr, CCA ) = AddressTranslation( vAddr, DATA, LOAD )
halfwordGPRLEN..0 = LoadMemory( CCA, HALFWORD, pAddr, vAddr, DATA )
GPR[rd]63..0 = sign_extend( halfword15..0 )

Exceptions:

Reserved Instruction, DSP Disabled, TLB Refill, TLB Invalid, Bus Error, Address Error, Watch

Encoding:

SPECIAL3

011111

base

index

rd

LWX

00000

LX

001010

6

5

5

5

5

6

Format:

LWX rd, index(base)

MIPSDSP

Load Word Indexed

Purpose:

Load Word Indexed

To load a word value from memory as a signed value, using indexed addressing.

Description:

 rd = memory[base+index]

The contents of GPR index is added to the contents of GPR base to form an effective address. The contents of the 32bit word at the memory location specified by the aligned effective address are fetched, sign-extended to the length of the GPR register, and placed in GPR rd.

Restrictions:

The effective address must be naturally-aligned. If either of the two least-significant bits of the address are non-zero, an Address Error exception occurs.

Operation:

vAddr31..0 = GPR[index]31..0 + GPR[base]31..0
if ( vAddr1..0 != 02 ) then
   SignalException( AddressError )
endif
( pAddr, CCA ) = AddressTranslation( vAddr, DATA, LOAD )
memwordGPRLEN..0 = LoadMemory( CCA, WORD, pAddr, vAddr, DATA )
GPR[rd]63..0 = sign_extend( memword31..0 )

Exceptions:

Reserved Instruction, DSP Disabled, TLB Refill, TLB Invalid, Bus Error, Address Error, Watch

Encoding:

SPECIAL2

011100

rs

rt

0

000

ac

0

MADD

000000

6

5

5

3

2

5

6

Format:

MADD ac, rs, rt

MIPS32 pre-Release 6, MIPSDSP

Multiply Word and Add to Accumulator

Purpose:

Multiply Word and Add to Accumulator

To multiply two 32-bit integer words and add the 64-bit result to the specified accumulator.

Description:

 (HI[ac]||LO[ac]) = (HI[ac]||LO[ac]) + (rs31..0 * rt31..0)

The 32-bit signed integer word in register rs is multiplied by the corresponding 32-bit signed integer word in register

rt to produce a 64-bit result. The 64-bit product is added to the specified 64-bit accumulator.

These special registers HI and LO are specified by the value of ac. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture.

In Release 6 of the MIPS Architecture, accumulators are eliminated from MIPS64.

No arithmetic exception occurs under any circumstances.

Restrictions:

If registers rs or rt do not contain sign-extended 32-bit values (i.e., bits 31 through 63 are equal), then the results of the operation are UNPREDICTABLE.

This instruction does not provide the capability of writing directly to a target GPR.

Operation:

 if NotWordValue(GPR[rs]) or NotWordValue(GPR[rt])) then
   UNPREDICTABLE 
endif
temp63..0 = ((GPR[rs]31)32 || GPR[rs]31..0) * ((GPR[rt]31)32 || GPR[rt]31..0)
acc63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) + temp63..0
( HI[ac]63..0 || LO[ac]63..0 ) = (acc63)32 || acc63..32 || (acc31)32 || acc31..0

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

In some processors the integer multiply operation may proceed asynchronously and allow other CPU instructions to execute before it is complete. An attempt to read LO or HI before the results are written interlocks until the results are ready. Asynchronous execution does not affect the program result, but offers an opportunity for performance improvement by scheduling the multiply so that other instructions can execute in parallel.

Programs that require overflow detection must check for it explicitly.

Where the size of the operands are known, software should place the shorter operand in register rt. This may reduce the latency of the instruction on those processors which implement data-dependent instruction latencies.

Encoding:

SPECIAL2

011100

rs

rt

0

000

ac

0

MADDU

000001

6

5

5

3

2

5

6

Format:

MADDU ac, rs, rt

MIPS32 pre-Release 6, MIPSDSP

Multiply Unsigned Word and Add to Accumulator

Purpose:

Multiply Unsigned Word and Add to Accumulator

To multiply two 32-bit unsigned integer words and add the 64-bit result to the specified accumulator.

Description:

 (HI[ac]||LO[ac]) = (HI[ac]||LO[ac]) + (rs31..0 * rt31..0)

The 32-bit unsigned integer word in register rs is multiplied by the corresponding 32-bit unsigned integer word in register rt to produce a 64-bit result. The 64-bit product is added to the specified 64-bit accumulator.

These special registers HI and LO are specified by the value of ac. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture.

In Release 6 of the MIPS Architecture, accumulators are eliminated from MIPS64.

No arithmetic exception occurs under any circumstances.

Restrictions:

If registers rs or rt do not contain sign-extended 32-bit values (i.e., bits 31 through 63 are equal), then the results of the operation are UNPREDICTABLE.

This instruction does not provide the capability of writing directly to a target GPR.

Operation:

 if NotWordValue(GPR[rs]) or NotWordValue(GPR[rt])) then
   UNPREDICTABLE 
endif
temp64..0 = (032 || GPR[rs]31..0 ) * ( 032 || GPR[rt]31..0 )
acc63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) + temp63..0
( HI[ac]63..0 || LO[ac]63..0 ) = (acc63)32 || acc63..32 || (acc31)32 || acc31..0

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

In some processors the integer multiply operation may proceed asynchronously and allow other CPU instructions to execute before it is complete. An attempt to read LO or HI before the results are written interlocks until the results are ready. Asynchronous execution does not affect the program result, but offers an opportunity for performance improvement by scheduling the multiply so that other instructions can execute in parallel.

Programs that require overflow detection must check for it explicitly.

Where the size of the operands are known, software should place the shorter operand in register rt. This may reduce the latency of the instruction on those processors which implement data-dependent instruction latencies.

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

MAQ_S.W.PHL

10100

DPA.W.PH

110000

SPECIAL3

011111

rs

rt

0

000

ac

MAQ_SA.W.PHL

10000

DPA.W.PH

110000

6

5

5

3

2

5

6

Format:

MAQ_S[A].W.PHL 

Multiply with Accumulate Single Vector Fractional Halfword Element

MAQ_S.W.PHL  ac, rs, rt 

MIPSDSP

Multiply with Accumulate Single Vector Fractional Halfword Element

MAQ_SA.W.PHL ac, rs, rt

MIPSDSP

Multiply with Accumulate Single Vector Fractional Halfword Element

Purpose:

Multiply with Accumulate Single Vector Fractional Halfword Element

To multiply one pair of elements from two vectors of fractional halfword values using full-sized intermediate products and accumulate the result into the specified 64-bit accumulator, with optional saturating accumulation.

Description:

ac = sat32(ac + sat32(rs31..16 * rt31..16))

The left-most Q15 fractional halfword values from the two right-most paired halfword vectors in each of registers rt and rs are multiplied together, and the product left-shifted by one bit position to generate a Q31 fractional format intermediate result. If both multiplicands are equal to -1.0 in Q15 fractional format (0x8000 hexadecimal), the intermediate result is saturated to the maximum positive Q31 fractional value (0x7FFFFFFF hexadecimal). The intermediate result is then sign-extended and accumulated into accumulator ac to generate a 64-bit Q32.31 fractional format result.

In the saturating accumulation variant of this instruction, if the accumulation of the intermediate product with the accumulator results in a value that cannot be represented as a Q31 fractional format value, the accumulator is saturated to either the maximum positive Q31 fractional format value (0x7FFFFFFF hexadecimal) or the minimum negative Q31 fractional format value (0x80000000), sign-extended to 64 bits.

The value of ac can range from 0 to 3; a value of 0 refers to the original HI/LO register pair of the MIPS64 architecture.

If overflow or saturation occurs, a 1 is written to one of bits 16 through 19 of the DSPControl register, within the

ouflag field. The value of ac determines which of these bits is set: bit 16 corresponds to ac0, bit 17 to ac1, bit 18 to ac2, and bit 19 to ac3.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the result is UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

MAQ_S.W.PHL:
   tempA31..0 = multiplyQ15Q15( ac, GPR[rs]31..16, GPR[rt]31..16 )
   tempB63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) + ( (tempA31)32 || tempA31..0 )
   ( HI[ac]63..0 || LO[ac]63..0 )  = (tempB63)32 || tempB63..32 || (tempB31)32 || tempB31..0
MAQ_SA.W.PHL:
   tempA31..0 = multiplyQ15Q15( ac, GPR[rs]31..16, GPR[rt]31..16 )
   tempA31..0 = sat32AccumulateQ31( ac, temp )
   tempB63..0 = (tempA31)32 || tempA31..0
   ( HI[ac]63..0 || LO[ac]63..0 )  = (tempB63)32 || tempB63..32 || (tempB31)32 || tempB31..0
function sat32AccumulateQ31( acc1..0, a31..0 )
   signA = a31
   temp127..0 = HI[acc]63..0 || LO[acc]63..0
   temp127..0 = temp + ( (signA)96 || a31..0 )
   if ( temp32 != temp31 ) then
      if ( temp32 = 0 ) then
          temp31..0 = 0x80000000
      else
          temp31..0 = 0x7FFFFFFF
      endif
      DSPControlouflag:16+acc = 1
   endif
   return temp31..0
endfunction sat32AccumulateQ31

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

The MAQ_SA version of the instruction is useful for compliance with some ITU speech processing codecs that require a 32-bit saturation after every multiply-accumulate operation.

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

MAQ_S.W.PHR

10110

DPA.W.PH

110000

SPECIAL3

011111

rs

rt

0

000

ac

MAQ_SA.W.PHR

10010

DPA.W.PH

110000

6

5

5

3

2

5

6

Format:

MAQ_S[A].W.PHR 

Multiply with Accumulate Single Vector Fractional Halfword Element

MAQ_S.W.PHR  ac, rs, rt 

MIPSDSP

Multiply with Accumulate Single Vector Fractional Halfword Element

MAQ_SA.W.PHR ac, rs, rt

MIPSDSP

Multiply with Accumulate Single Vector Fractional Halfword Element

Purpose:

Multiply with Accumulate Single Vector Fractional Halfword Element

To multiply one pair of elements from two vectors of fractional halfword values using full-sized intermediate products and accumulate the result into the specified 64-bit accumulator, with optional saturating accumulation.

Description:

ac = sat32(ac + sat32(rs15..0 * rt15..0))

The right-most Q15 fractional halfword values from each of the registers rt and rs are multiplied together and the product left-shifted by one bit position to generate a Q31 fractional format intermediate result. If both multiplicands are equal to -1.0 in Q15 fractional format (0x8000 hexadecimal), the intermediate result is saturated to the maximum positive Q31 fractional value (0x7FFFFFFF hexadecimal). The intermediate result is then sign-extended and accumulated into accumulator ac to generate a 64-bit Q32.31 fractional format result.

In the saturating accumulation variant of this instruction, if the accumulation of the intermediate product with the accumulator results in a value that cannot be represented as a Q31 fractional format value, the accumulator is saturated to either the maximum positive Q31 fractional format value (0x7FFFFFFF hexadecimal) or the minimum negative Q31 fractional format value (0x80000000), sign-extended to 64 bits.

The value of ac can range from 0 to 3; a value of 0 refers to the original HI/LO register pair of the MIPS64 architecture.

If overflow or saturation occurs, a 1 is written to one of bits 16 through 19 of the DSPControl register, within the

ouflag field. The value of ac determines which of these bits is set: bit 16 corresponds to ac0, bit 17 to ac1, bit 18 to ac2, and bit 19 to ac3.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the result is UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

MAQ_S.W.PHR:
   tempA31..0 = multiplyQ15Q15( ac, GPR[rs]15..0, GPR[rt]15..0 )
   tempB63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) + ( (tempA31)32 || tempA31..0 )
   ( HI[ac]63..0 || LO[ac]63..0 )  = (tempB63)32 || tempB63..32 || (tempB31)32 || tempB31..0
MAQ_SA.W.PHR:
   tempA31..0 = multiplyQ15Q15( ac, GPR[rs]15..0, GPR[rt]15..0 )
   tempA31..0 = sat32AccumulateQ31( ac, temp )
   tempB63..0 = (tempA31)32 || tempA31..0
   ( HI[ac]63..0 || LO[ac]63..0 )  = (tempB63)32 || tempB63..32 || (tempB31)32 || tempB31..0

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

The MAQ_SA version of the instruction is useful for compliance with some ITU speech processing codecs that require a 32-bit saturation after every multiply-accumulate operation.

Encoding:

SPECIAL

000000

0

000

ac

0

00000

rd

0

00000

MFHI

010000

6

3

2

5

5

5

6

Format:

MFHI rd, ac

MIPS32 pre-Release 6, MIPSDSP

Move from HI register

Purpose:

Move from HI register

To copy the special purpose HI register to a GPR.

Description:

rd = HI[ac]

The HI part of accumulator ac is copied to the general-purpose register rd. The HI part of the accumulator is defined to be bits 64 through 127 of the DSP Module accumulator register.

The value of ac can range from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture.

In Release 6 of the MIPS Architecture, accumulators are eliminated from MIPS64.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

 GPR[rd]63..0 = HI[ac]63..0 

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL

000000

0

000

ac

0

00000

rd

0

00000

MFLO

010010

6

3

2

5

5

5

6

Format:

MFLO rd, ac

MIPS32 pre-Release 6, MIPSDSP

Move from LO register

Purpose:

Move from LO register

To copy the special purpose LO register to a GPR.

Description:

rd = LO[ac]

The LO part of accumulator ac iscopied to the general-purpose register rd. The LO part of the accumulator is defined to be bits 0 through 63 of the DSP Module accumulator register.

The value of ac can range from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture.

In Release 6 of the MIPS Architecture, accumulators are eliminated from MIPS64.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

 GPR[rd]63..0 = LO[ac]63..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

MODSUB

10010

ADDU.QB

010000

6

5

5

5

5

6

Format:

MODSUB  rd, rs, rt

MIPSDSP

Modular Subtraction on an Index Value

Purpose:

Modular Subtraction on an Index Value

Do a modular subtraction on a specified index value, using the specified decrement and modular roll-around values.

Description:

rd = (GPR[rs]==0 ? zero_extend(GPR[rt]23..8) : GPR[rs] - GPR[rt]7..0)

The right-most 32-bit value in register rs is compared to the value zero. If it is zero, then the index value has reached the bottom of the buffer and must be rolled back around to the top of the buffer. The index value of the top element of the buffer is obtained from bits 8 through 23 in register rt; this value is zero-extended to 64 bits and written to destination register rd.

If the value of register rs is not zero, then it is simply decremented by the size of the elements in the buffer. The size of the elements, in bytes, is specified by bits 0 through 7 of register rt, interpreted as an unsigned integer.

This instruction does not modify the ouflag field in the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

decr7..0 = GPR[rt]7..0
lastindex15..0 = GPR[rt]23..8
if ( GPR[rs]31..0 = 0x00000000 ) then
   GPR[rd]63..0 = 0(GPRLEN-16) || lastindex15..0
else
   GPR[rd]63..0 = GPR[rs]63..0 - decr7..0
endif

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL2

011100

rs

rt

0

000

ac

0

00000

MSUB

000100

6

5

5

3

2

5

6

Format:

MSUB ac, rs, rt

MIPS32 pre-Release 6, MIPSDSP

Multiply Word and Subtract from Accumulator

Purpose:

Multiply Word and Subtract from Accumulator

To multiply two 32-bit integer words and subtract the 64-bit result from the specified accumulator.

Description:

 (HI[ac]||LO[ac]) = (HI[ac]||LO[ac]) - (rs31..0 * rt31..0)

The 32-bit signed integer word in register rs is multiplied by the corresponding 32-bit signed integer word in register

rt to produce a 64-bit result. The 64-bit product is subtracted from the specified 64-bit accumulator.

These special registers HI and LO are specified by the value of ac. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture.

In Release 6 of the MIPS Architecture, accumulators are eliminated from MIPS64.

No arithmetic exception occurs under any circumstances.

Restrictions:

If registers rs or rt do not contain sign-extended 32-bit values (i.e., bits 31 through 63 are equal), then the results of the operation are UNPREDICTABLE.

This instruction does not provide the capability of writing directly to a target GPR.

Operation:

 if NotWordValue(GPR[rs]) or NotWordValue(GPR[rt])) then
   UNPREDICTABLE 
endif
temp63..0 = ((GPR[rs]31)32 || GPR[rs]31..0) * ((GPR[rt]31)32 || GPR[rt]31..0)
acc63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) - temp63..0
( HI[ac]63..0 || LO[ac]63..0 ) = (acc63)32 || acc63..32 || (acc31)32 || acc31..0

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

In some processors the integer multiply operation may proceed asynchronously and allow other CPU instructions to execute before it is complete. An attempt to read LO or HI before the results are written interlocks until the results are ready. Asynchronous execution does not affect the program result, but offers an opportunity for performance improvement by scheduling the multiply so that other instructions can execute in parallel.

Programs that require overflow detection must check for it explicitly.

Where the size of the operands are known, software should place the shorter operand in register rt. This may reduce the latency of the instruction on those processors which implement data-dependent instruction latencies.

Encoding:

SPECIAL2

011100

rs

rt

0

000

ac

0

00000

MSUBU

000101

6

5

5

3

2

5

6

Format:

MSUBU ac, rs, rt

MIPS32 pre-Release 6, MIPSDSP

Multiply Unsigned Word and Add to Accumulator

Purpose:

Multiply Unsigned Word and Add to Accumulator

To multiply two 32-bit unsigned integer words and subtract the 64-bit result from the specified accumulator.

Description:

 (HI[ac]||LO[ac]) = (HI[ac]||LO[ac]) - (rs31..0 * rt31..0)

The 32-bit unsigned integer word in register rs is multiplied by the corresponding 32-bit unsigned integer word in register rt to produce a 64-bit result. The 64-bit product is subtracted from the specified 64-bit accumulator.

These special registers HI and LO are specified by the value of ac. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture.

In Release 6 of the MIPS Architecture, accumulators are eliminated from MIPS64.

No arithmetic exception occurs under any circumstances.

Restrictions:

If registers rs or rt do not contain sign-extended 32-bit values (i.e., bits 31 through 63 are equal), then the results of the operation are UNPREDICTABLE.

This instruction does not provide the capability of writing directly to a target GPR.

Operation:

 if NotWordValue(GPR[rs]) or NotWordValue(GPR[rt])) then
   UNPREDICTABLE 
endif
temp64..0 = (032 || GPR[rs]31..0 ) * ( 032 || GPR[rt]31..0 )
acc63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) - temp63..0
( HI[ac]63..0 || LO[ac]63..0 ) = (acc63)32 || acc63..32 || (acc31)32 || acc31..0

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

In some processors the integer multiply operation may proceed asynchronously and allow other CPU instructions to execute before it is complete. An attempt to read LO or HI before the results are written interlocks until the results are ready. Asynchronous execution does not affect the program result, but offers an opportunity for performance improvement by scheduling the multiply so that other instructions can execute in parallel.

Programs that require overflow detection must check for it explicitly.

Where the size of the operands are known, software should place the shorter operand in register rt. This may reduce the latency of the instruction on those processors which implement data-dependent instruction latencies.

Encoding:

SPECIAL

000000

rs

0

00000000

ac

0

00000

MTHI

010001

6

5

8

2

5

6

Format:

MTHI rs, ac

MIPS32 pre-Release 6, MIPSDSP

Move to HI register

Purpose:

Move to HI register

To copy a GPR to the special purpose HI part of the specified accumulator register.

Description:

HI[ac] = GPR[rs]

The source register rs is copied to the HI part of accumulator ac. The HI part of the accumulator is defined to be bits

64 to 127 of the DSP Module accumulator register.

The value of ac can range from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture.

In Release 6 of the MIPS Architecture, accumulators are eliminated from MIPS64.

Restrictions:

A computed result written to the HI/LO pair by DIV, DIVU, DDIV, DDIVU, DMULT, DMULTU, MULT, or MULTU must be read by MFHI or MFLO before a new result can be written into either HI or LO. Note that this restriction only applies to the original HI/LO accumulator pair, and does not apply to the new accumulators, ac1, ac2, and ac3.

If an MTHI instruction is executed following one of these arithmetic instructions, but before an MFLO or MFHI instruction, the contents of LO are UNPREDICTABLE. The following example shows this illegal situation:

MULT r2,r4 # start operation that will eventually write to HI,LO
...        # code not containing mfhi or mflo
MTHI r6
...        # code not containing mflo
MFLO r3    # this mflo would get an UNPREDICTABLE value

Operation:

HI[ac]63..0 = GPR[rs]63..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

0

00000000

ac

MTHLIP

11111

EXTR.W

111000

6

5

8

2

5

6

Format:

MTHLIP rs, ac

MIPSDSP

Copy LO to HI and a GPR to LO and Increment Pos by 32

Purpose:

Copy LO to HI and a GPR to LO and Increment Pos by 32

Copy the LO part of an accumulator to the HI part, copy a GPR to LO, and increment the pos field in the DSPControl register by 32.

Description:

ac = sign_extend(LO[ac]31..0) || sign_extend(GPR[rs]31..0) ; DSPControlpos:6..0 += 32

The 32 least-significant bits of the specified accumulator are sign-extended to 64 bits and copied to the most-significant 64 bits of the same accumulator. Then the 32 least-significant bits of register rs are sign-extended to 64 bits and copied to the least-significant 64 bits of the accumulator. The instruction then increments the value of bits 0 through 6 of the DSPControl register (the pos field) by 32.

The result of this instruction is UNPREDICTABLE if the value of the pos field before the execution of the instruction is greater than 32.

The value of ac can range from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempA63..0 = ( (GPR[rs]31)32 || GPR[rs]31..0 )
tempB63..0 = ( (LO[ac]31)32) || LO[ac]31..0 )
( HI[ac]63..0 || LO[ac]63..0 ) = tempB63..0 || tempA63..0
oldpos6..0 = DSPControlpos:6..0
if ( oldpos6..0 > 32 ) then
   DSPControlpos:6..0 = UNPREDICTABLE
else
   DSPControlpos:6..0 = oldpos6..0 + 32
endif

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL

000000

rs

0

00000000

ac

0

00000

MTLO

010011

6

5

8

2

5

6

Format:

MTLO rs, ac

MIPS32 pre-Release 6, MIPSDSP

Move to LO register

Purpose:

Move to LO register

To copy a GPR to the special purpose LO part of the specified accumulator register.

Description:

LO[ac] = GPR[rs]

The source register rs is copied to the LO part of accumulator ac. The LO part of the accumulator is defined to be bits

0 to 63 of the DSP Module accumulator register.

The value of ac can range from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture.

In Release 6 of the MIPS Architecture, accumulators are eliminated from MIPS64.

Restrictions:

A computed result written to the HI/LO pair by DIV, DIVU, DDIV, DDIVU, DMULT, DMULTU, MULT, or MULTU must be read by MFHI or MFLO before a new result can be written into either HI or LO. Note that this restriction only applies to the original HI/LO accumulator pair, and does not apply to the new accumulators, ac1, ac2, and ac3.

If an MTHI instruction is executed following one of these arithmetic instructions, but before an MFLO or MFHI instruction, the contents of LO are UNPREDICTABLE. The following example shows this illegal situation:

MULT r2,r4 # start operation that will eventually write to HI,LO
...        # code not containing mfhi or mflo
MTHI r6
...        # code not containing mflo
MFLO r3    # this mflo would get an UNPREDICTABLE value

Operation:

 LO[ac]63..0 = GPR[rs]63..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

MULEQ_S.W.PHL

11100

ADDU.QB

010000

6

5

5

5

5

6

Format:

MULEQ_S.W.PHL rd, rs, rt

MIPSDSP

Multiply Vector Fractional Left Halfwords to Expanded Width Products

Purpose:

Multiply Vector Fractional Left Halfwords to Expanded Width Products

Multiply two Q15 fractional halfword values to produce a Q31 fractional word result, with saturation.

Description:

rd = sign_extend(sat32(rs31..16 * rt31..16))

The left-most Q15 fractional halfword value from the right-most paired halfword vector in register rs is multiplied by the corresponding Q15 fractional halfword value from register rt. The result is left-shifted one bit position to create a

Q31 format result, sign-extended to 64 bits, and written into the destination register rd. If both input values are -1.0 in

Q15 format (0x8000 in hexadecimal) the result is clamped to the maximum positive Q31 fractional value

(0x7FFFFFFF in hexadecimal) before being sign-extended and written to the destination register.

To stay compliant with the base architecture, this instruction leaves the base HI/LO pair (accumulator ac0) UNPREDICTABLE after the operation completes. The other DSP Module accumulators, ac1, ac2, and ac3 are unmodified.

If the result is saturated, this instruction writes a 1 to bit 21 in the ouflag field of the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

temp31..0 = multiplyQ15Q15ouflag21( GPR[rs]31..16, GPR[rt]31..16 )
GPR[rd]63..0 = (temp31)32 || temp31..0
HI[0]63..0 = UNPREDICTABLE
LO[0]63..0 = UNPREDICTABLE
function multiplyQ15Q15ouflag21( a15..0, b15..0 )
   if ( a15..0 = 0x8000 ) and ( b15..0 = 0x8000 ) then
      temp31..0 = 0x7FFFFFFF
      DSPControlouflag:21 = 1
   else
      temp31..0 = ( a15..0 * b15..0 ) << 1
   endif
   return temp31..0
endfunction multiplyQ15Q15ouflag21

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

The base MIPS64 architecture states that after a GPR-targeting multiply instruction such as MUL, the contents of registers HI and LO are UNPREDICTABLE. To maintain compliance with the base architecture this multiply instruction, MULEQ_S.W.PHL, has the same requirement. Software must save and restore the ac0 register if the previous value in the ac0 register is needed following the MULEQ_S.W.PHL instruction.

Note that the requirement on HI and LO does not apply to the new accumulator registers ac1, ac2, and ac3; as a result the values in these accumulators need not be saved.

Encoding:

SPECIAL3

011111

rs

rt

rd

MULEQ_S.W.PHR

11101

ADDU.QB

010000

6

5

5

5

5

6

Format:

MULEQ_S.W.PHR rd, rs, rt

MIPSDSP

Multiply Vector Fractional Right Halfwords to Expanded Width Products

Purpose:

Multiply Vector Fractional Right Halfwords to Expanded Width Products

Multiply two Q15 fractional halfword values to produce a Q31 fractional word result, with saturation.

Description:

rd = sign_extend(sat32(rs15..0 * rt15..0))

The right-most Q15 fractional halfword value from register rs is multiplied by the corresponding Q15 fractional halfword value from register rt. The result is left-shifted one bit position to create a Q31 format result, sign-extended to

64 bits, and written into the destination register rd. If both input values are -1.0 in Q15 format (0x8000 in hexadecimal) the result is clamped to the maximum positive Q31 fractional value (0x7FFFFFFF in hexadecimal) before being sign-extended and written to the destination register.

To stay compliant with the base architecture, this instruction leaves the base HI/LO pair (accumulator ac0) UNPREDICTABLE after the operation completes. The other DSP Module accumulators, ac1, ac2, and ac3 are unmodified.

If the result is saturated, this instruction writes a 1 to bit 21 in the ouflag field of the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

temp31..0 = multiplyQ15Q15ouflag21( GPR[rs]15..0, GPR[rt]15..0 )
GPR[rd]63..0 = (temp31)32 || temp31..0
HI[0]63..0 = UNPREDICTABLE
LO[0]63..0 = UNPREDICTABLE
function multiplyQ15Q15ouflag21( a15..0, b15..0 )
   if ( a15..0 = 0x8000 ) and ( b15..0 = 0x8000 ) then
      temp31..0 = 0x7FFFFFFF
      DSPControlouflag:21 = 1
   else
      temp31..0 = ( a15..0 * b15..0 ) << 1
   endif
   return temp31..0
endfunction multiplyQ15Q15ouflag21

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

The base MIPS64 architecture states that after a GPR-targeting multiply instruction such as MUL, the contents of registers HI and LO are UNPREDICTABLE. To maintain compliance with the base architecture this multiply instruction, MULEQ_S.W.PHR, has the same requirement. Software must save and restore the ac0 register if the previous value in the ac0 register is needed following the MULEQ_S.W.PHR instruction.

Note that the requirement on HI and LO does not apply to the new accumulator registers ac1, ac2, and ac3; as a result the values in these accumulators need not be saved.

Encoding:

SPECIAL3

011111

rs

rt

rd

MULEU_S.PH.QBL

00110

ADDU.QB

010000

6

5

5

5

5

6

Format:

MULEU_S.PH.QBL rd, rs, rt

MIPSDSP

Multiply Unsigned Vector Left Bytes by Halfwords to Halfword Products

Purpose:

Multiply Unsigned Vector Left Bytes by Halfwords to Halfword Products

Multiply two left-most unsigned byte vector elements in a four-element byte vector by two unsigned halfword vector elements to produce two unsigned halfword results, with saturation.

Description:

rd = sign_extend(sat16(rs31..24 * rt31..16) || sat16(rs23..16 * rt15..0))

The two left-most unsigned byte elements in the right-mostfour-element byte vector in register rs are multiplied as unsigned integer values with the four corresponding unsigned halfword elements from register rt. The eight most-significant bits of each 24-bit result are discarded, and the remaining 16 least-significant bits are written to the corresponding elements in halfword vector register rd. The instruction saturates the result to the maximum positive value

(0xFFFF hexadecimal) if any of the discarded bits from each intermediate result are non-zero.

Bit 31 of the result is extended into the 32 most-significant bits of the destination register.

To stay compliant with the base architecture, this instruction leaves the base HI/LO pair (accumulator ac0) UNPREDICTABLE after the operation completes. The other DSP Module accumulators, ac1, ac2, and ac3 are unmodified.

If either result is saturated this instruction writes a 1 to bit 21 in the DSPControl register in the ouflag field.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = multiplyU8U16( GPR[rs]31..24, GPR[rt]31..16 )
tempA15..0 = multiplyU8U16( GPR[rs]23..16, GPR[rt]15..0 )
GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0 
HI[0]63..0 = UNPREDICTABLE
LO[0]63..0 = UNPREDICTABLE
function multiplyU8U16( a7..0, b15..0 )
   temp25..0 = (0 || a) * (0 || b)
   if ( temp25..16> 0x00 ) then
      temp25..0 = 010 || 0xFFFF
      DSPControlouflag:21 = 1
   endif
   return temp15..0
endfunction multiplyU8U16

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

The base MIPS64 architecture states that after a GPR-targeting multiply instruction such as MUL, the contents of registers HI and LO are UNPREDICTABLE. To maintain compliance with the base architecture this multiply instruction, MULEU_S.PH.QBL, has the same requirement. Software must save and restore the ac0 register if the previous value in the ac0 register is needed following the MULEU_S.PH.QBL instruction.

Note that the requirement on HI and LO does not apply to the new accumulator registers ac1, ac2, and ac3; as a result the values in these accumulators need not be saved.

Encoding:

SPECIAL3

011111

rs

rt

rd

MULEU_S.PH.QBR

00111

ADDU.QB

010000

6

5

5

5

5

6

Format:

MULEU_S.PH.QBR rd, rs, rt

MIPSDSP

Multiply Unsigned Vector Right Bytes with halfwords to Half Word Products

Purpose:

Multiply Unsigned Vector Right Bytes with halfwords to Half Word Products

Element-wise multiplication of unsigned byte elements with corresponding unsigned halfword elements, with saturation.

Description:

rd = sign_extend(sat16(rs15..8 * rt31..16) || sat16(rs7..0 * rt15..0))

The two right-most unsigned byte elements in the right-mostfour-element byte vector in register rs are multiplied as unsigned integer values with the corresponding right-most 16-bit unsigned values from register rt. Each result is clipped to preserve the 16 least-significant bits and written back into the respective halfword element positions in the destination register rd. The instruction saturates the result to the maximum positive value (0xFFFF hexadecimal) if any of the clipped bits are non-zero.

Bit 31 of the result is extended into the 32 most-significant bits of the destination register.

To stay compliant with the base architecture, this instruction leaves the base HI/LO pair (accumulator ac0) UNPREDICTABLE after the operation completes. The other DSP Module accumulators, ac1, ac2, and ac3 must be unmodified.

This instruction writes a 1 to bit 21 in the ouflag field in the DSPControl register if either multiplication results in saturation.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = multiplyU8U16( GPR[rs]15..8, GPR[rt]31..16 )
tempA15..0 = multiplyU8U16( GPR[rs]7..0, GPR[rt]15..0 )
GPR[rd] = (tempB15)32 || tempB15..0 || tempA15..0
HI[0]63..0 = UNPREDICTABLE
LO[0]63..0 = UNPREDICTABLE

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

The base MIPS64 architecture states that after a GPR-targeting multiply instruction such as MUL, the contents of registers HI and LO are UNPREDICTABLE. To maintain compliance with the base architecture this multiply instruction, MULEU_S.PH.QBR, has the same requirement. Software must save and restore the ac0 register if the previous value in the ac0 register is needed following the MULEU_S.PH.QBR instruction.

Note that the requirement on HI and LO does not apply to the new accumulator registers ac1, ac2, and ac3; as a result the values in these accumulators need not be saved.

Encoding:

SPECIAL3

011111

rs

rt

rd

MULQ_RS.PH

11111

ADDU.QB

010000

6

5

5

5

5

6

Format:

MULQ_RS.PH rd, rs, rt

MIPSDSP

Multiply Vector Fractional Halfwords to Fractional Halfword Products

Purpose:

Multiply Vector Fractional Halfwords to Fractional Halfword Products

Multiply Q15 fractional halfword vector elements with rounding and saturation to produce two Q15 fractional halfword results.

Description:

rd = sign_extend(rndQ15(rs31..16 * rt31..16) || rndQ15(rs15..0 * rt15..0))

The two right-most Q15 fractional halfword elements from register rs are separately multiplied by the corresponding

Q15 fractional halfword elements from register rt to produce 32-bit intermediate results. Each intermediate result is left-shifted by one bit position to produce a Q31 fractional value, then rounded by adding 0x00008000 hexadecimal.

The rounded intermediate result is then truncated to a Q15 fractional value and written to the corresponding position in destination register rd.

The sign of the left-most result is extended into the 32 most-significant bits of the destination register.

If the two input values to either multiplication are both -1.0 (0x8000 in hexadecimal), the final halfword result is saturated to the maximum positive Q15 value (0x7FFF in hexadecimal) and rounding and truncation are not performed.

To stay compliant with the base architecture, this instruction leaves the base HI/LO pair (accumulator ac0) UNPREDICTABLE after the operation completes. The other DSP Module accumulators, ac1, ac2, and ac3 must be unmodified.

If either result is saturated this instruction writes a 1 to bit 21 in the DSPControl register in the ouflag field.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = rndQ15MultiplyQ15Q15( GPR[rs]31..16, GPR[rt]31..16 )
tempA15..0 = rndQ15MultiplyQ15Q15( GPR[rs]15..0, GPR[rt]15..0 )
GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0 
HI[0]63..0 = UNPREDICTABLE
LO[0]63..0 = UNPREDICTABLE
function rndQ15MultiplyQ15Q15( a15..0, b15..0 )
   if ( a15..0 = 0x8000 ) and ( b15..0 = 0x8000 ) then
      temp31..0 = 0x7FFF0000
      DSPControlouflag:21 = 1
   else
      temp31..0 = ( a15..0 * b15..0 ) << 1
      temp31..0 = temp31..0 + 0x00008000
   endif
   return temp31..16
endfunction rndQ15MultiplyQ15Q15

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

The base MIPS64 architecture states that after a GPR-targeting multiply instruction such as MUL, the contents of registers HI and LO are UNPREDICTABLE. To maintain compliance with the base architecture, this multiply instruction, MULQ_RS.PH, has the same requirement. Software must save and restore the ac0 register if the previous value in the ac0 register is needed following the MULQ_RS.PH instruction.

Note that the requirement on HI and LO does not apply to the new accumulator registers ac1, ac2, and ac3; as a result, the values in these accumulators need not be saved.

Encoding:

SPECIAL3

011111

rs

rt

rd

MULQ_RS.W

10111

MUL.PH

011000

6

5

5

5

5

6

Format:

MULQ_RS.W rd, rs, rt

MIPSDSP-R2

Multiply Fractional Words to Same Size Product with Saturation and Rounding

Purpose:

Multiply Fractional Words to Same Size Product with Saturation and Rounding

Multiply fractional Q31 word values, with saturation and rounding.

Description:

rd = sign_extend(round(sat32(rs31..0 * rt31..0)))

The right-most Q31 fractional format words in registers rs and rt are multiplied together and the product shifted left by one bit position to create a 64-bit fractional format intermediate result. The intermediate result is rounded up by adding a 1 at bit position 31, and then truncated by discarding the 32 least-significant bits to create a 32-bit fractional format result. The result is then sign-extended to 64 bits and written to destination register rd.

If both input multiplicands are equal to -1 (0x80000000 hexadecimal), rounding is not performed and the maximum positive Q31 fractional format value (0x7FFFFFFF hexadecimal) is sign-extended to 64 bits and written to the destination register.

To stay compliant with the base architecture, this instruction leaves the base HI/LO pair (accumulator ac0) UNPREDICTABLE after the operation completes. The other DSP Module accumulators, ac1, ac2, and ac3, are unchanged.

This instruction, on an overflow or underflow of the operation, writes a 1 to bit 21 in the DSPControl register in the

ouflag field.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

if ( GPR[rs]31..0 = 0x80000000 ) and ( GPR[rt]31..0 = 0x80000000 ) then
   temp63..0 = 0x7FFFFFFF00000000
   DSPControlouflag:21 = 1
else 
   temp63..0 = ( GPR[rs]31..0 * GPR[rt]31..0 ) << 1
   temp63..0 = temp63..0 + ( 032 || 0x80000000 )
endif
GPR[rd]63..0 = (temp63)32 || temp63..32
HI[0]63..0 = UNPREDICTABLE
LO[0]63..0 = UNPREDICTABLE

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

The base MIPS64 architecture states that after a GPR-targeting multiply instruction such as MUL, the contents of registers HI and LO are UNPREDICTABLE. To maintain compliance with the base architecture, this multiply instruction, MULQ_RS.W, has the same requirement. Software must save and restore the ac0 register if the previous value in the ac0 register is needed following the MULQ_RS.W instruction.

Note that the requirement on HI and LO does not apply to the new accumulator registers ac1, ac2, and ac3; as a result, the values in these accumulators need not be saved.

Encoding:

SPECIAL3

011111

rs

rt

rd

MULQ_S.PH

11110

ADDU.QB

010000

6

5

5

5

5

6

Format:

MULQ_S.PH rd, rs, rt

MIPSDSP-R2

Multiply Vector Fractional Half-Words to Same Size Products

Purpose:

Multiply Vector Fractional Half-Words to Same Size Products

Multiply two vector fractional Q15 values to create a Q15 result, with saturation.

Description:

rd = sign_extend(sat16(rs31..16 * rt31..16) || sat16(rs15..0 * rt15..0))

The two right-most vector fractional Q15 values in register rs are multiplied with the corresponding elements in register rt to produce two 32-bit products. Each product is left-shifted by one bit position to create a Q31 fractional word intermediate result. The two 32-bit intermediate results are then each truncated by discarding the 16 least-significant bits of each result, and the resulting Q15 fractional format halfwords are then written to the corresponding positions in destination register rd. For each halfword result, if both input multiplicands are equal to -1 (0x8000 hexadecimal), the final halfword result is saturated to the maximum positive Q15 value (0x7FFF hexadecimal).

The sign of the left-most halfword result is extended into the 32 most-significant bits of the destination register.

To stay compliant with the base architecture, this instruction leaves the base HI/LO pair (accumulator ac0) UNPREDICTABLE after the operation completes. The other DSP Module accumulators, ac1, ac2, and ac3, must be untouched.

This instruction, on an overflow or underflow of any one of the two vector operation, writes bit 21 in the ouflag field in the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB31..0 = sat16MultiplyQ15Q15( GPR[rs]31..16, GPR[rt]31..16 )
tempA31..0 = sat16MultiplyQ15Q15( GPR[rs]15..0, GPR[rt]15..0 )
GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0 
HI[0]63..0 = UNPREDICTABLE
LO[0]63..0 = UNPREDICTABLE
function sat16MultiplyQ15Q15( a15..0, b15..0 )
   if ( a15..0 = 0x8000 ) and ( b15..0 = 0x8000 ) then
      temp31..0 = 0x7FFF0000
      DSPControlouflag:21 = 1
   else
      temp31..0 = ( a15..0 * b15..0 )
      temp31..0 = ( temp30..0 || 0 )
   endif
   return temp31..16
endfunction sat16MultiplyQ15Q15

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

The base MIPS64 architecture states that after a GPR-targeting multiply instruction such as MUL, the contents of registers HI and LO are UNPREDICTABLE. To maintain compliance with the base architecture, this multiply instruction, MULQ_S.PH, has the same requirement. Software must save and restore the ac0 register if the previous value in the ac0 register is needed following the MULQ_S.PH instruction.

Note that the requirement on HI and LO does not apply to the new accumulator registers ac1, ac2, and ac3; as a result, the values in these accumulators need not be saved.

Encoding:

SPECIAL3

011111

rs

rt

rd

MULQ_S.W

10110

MUL.PH

011000

6

5

5

5

5

6

Format:

MULQ_S.W rd, rs, rt

MIPSDSP-R2

Multiply Fractional Words to Same Size Product with Saturation

Purpose:

Multiply Fractional Words to Same Size Product with Saturation

Multiply two Q31 fractional format word values to create a fractional Q31 result, with saturation.

Description:

rd = sign_extend(sat32(rs31..0 * rt31..0))

The right-most Q31 fractional format words in registers rs and rt are multiplied together to create a 64-bit fractional format intermediate result. The intermediate result is left-shifted by one bit position, and then truncated by discarding the 32 least-significant bits to create a Q31 fractional format result. This result is then sign-extended to 64 bits and written to destination register rd.

If both input multiplicands are equal to -1 (0x80000000 hexadecimal), the product is clipped to the maximum positive Q31 fractional format value (0x7FFFFFFF hexadecimal), and sign-extended to 64 bits and written to the destination register.

To stay compliant with the base architecture, this instruction leaves the base HI/LO pair (accumulator ac0) UNPREDICTABLE after the operation completes. The other DSP Module accumulators, ac1, ac2, and ac3, are unchanged.

This instruction, on an overflow or underflow of the operation, writes a 1 to bit 21 in the DSPControl register in the

ouflag field.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

if ( GPR[rs]31..0 = 0x80000000 ) and ( GPR[rt]31..0 = 0x80000000 ) then
   temp63..0 = 0x7FFFFFFF00000000
   DSPControlouflag:21 = 1
else 
   temp63..0 = ( GPR[rs]31..0 * GPR[rt]31..0 ) << 1
endif
GPR[rd]63..0 = (temp63)32 || temp63..32
HI[0]63..0 = UNPREDICTABLE
LO[0]63..0 = UNPREDICTABLE

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

The base MIPS64 architecture states that after a GPR-targeting multiply instruction such as MUL, the contents of registers HI and LO are UNPREDICTABLE. To maintain compliance with the base architecture, this multiply instruction, MULQ_S.W, has the same requirement. Software must save and restore the ac0 register if the previous value in the ac0 register is needed following the MULQ_S.W instruction.

Note that the requirement on HI and LO does not apply to the new accumulator registers ac1, ac2, and ac3; as a result, the values in these accumulators need not be saved.

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

MULSA.W.PH

00010

DPA.W.PH

110000

6

5

5

3

2

5

6

Format:

MULSA.W.PH ac, rs, rt

MIPSDSP-R2

Multiply and Subtract Vector Integer Halfword Elements and Accumulate

Purpose:

Multiply and Subtract Vector Integer Halfword Elements and Accumulate

To multiply and subtract two integer vector elements using full-size intermediate products, accumulating the result into the specified accumulator.

Description:

ac = ac + ((rs31..16 * rt31..16) - (rs15..0 * rt15..0))

Each of the two right-most halfword integer elements from register rt are multiplied by the corresponding elements in

rs to create two word results. The right-most result is subtracted from the left-most result to generate the intermediate

result, which is then added to the specified 64-bit accumulator.

The value of ac selects an accumulator numbered from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture.

This instruction does not set any bits of the ouflag field in the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the result is UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB31..0 = (GPR[rs]31..16 * GPR[rt]31..16)
tempA31..0 = (GPR[rs]15..0 * GPR[rt]15..0)
dotp32..0 = ( (tempB31) || tempB31..0 ) - ( (tempA31) || tempA31..0 )
acc63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) + ( (dotp32)31 || dotp32..0 )
( HI[ac]63..0 || LO[ac]63..0 ) = (acc63)32 || acc63..32 || (acc31)32 || acc31..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

0

000

ac

MULSAQ_S.W.PH

00110

DPA.W.PH

110000

6

5

5

3

2

5

6

Format:

MULSAQ_S.W.PH ac, rs, rt

MIPSDSP

Multiply And Subtract Vector Fractional Halfwords And Accumulate

Purpose:

Multiply And Subtract Vector Fractional Halfwords And Accumulate

Multiply and subtract two Q15 fractional halfword vector elements using full-size intermediate products, accumulating the result from the specified accumulator, with saturation.

Description:

ac = ac + (sat32(rs31..16 * rt31..16) - sat32(rs15..0 * rt15..0))

The two corresponding right-most Q15 fractional values from registers rt and rs are multiplied together and leftshifted by 1 bit to generate two Q31 fractional format intermediate products. If the input multiplicands to either of the multiplications are both -1.0 (0x8000 hexadecimal), the intermediate result is saturated to 0x7FFFFFFF hexadecimal.

The two intermediate products (named left and right) are summed with alternating sign to create a sum-of-products, i.e., the sign of the right product is negated before summation. The sum-of-products is then sign-extended to 64 bits and accumulated into the specified 64-bit accumulator, producing a Q32.31 result.

The value of ac can range from 0 to 3; a value of 0 refers to the original HI/LO register pair of the MIPS64 architecture.

If saturation occurs, a 1 is written to one of bits 16 through 19 of the DSPControl register, within the ouflag field. The value of ac determines which of these bits is set: bit 16 corresponds to ac0, bit 17 to ac1, bit 18 to ac2, and bit 19 to

ac3.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB31..0 = multiplyQ15Q15( ac, rs31..16, rt31..16 )
tempA31..0 = multiplyQ15Q15( ac, rs15..0, rt15..0 )
dotp63..0 = ( (tempB31)32 || tempB31..0 ) - ( (tempA31)32 || tempA31..0 )
tempC63..0 = ( HI[ac]31..0 || LO[ac]31..0 ) + dotp63..0
( HI[ac]63..0 || LO[ac]63..0 ) = (tempC63)32 || tempC63..32 || (tempC31)32 || tempC31..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL

000000

rs

rt

0

000

ac

0

00000

MULT

011000

6

5

5

3

2

5

6

Format:

MULT ac, rs, rt 

MIPS32 pre-Release 6, MIPSDSP

Multiply Word

Purpose:

Multiply Word

To multiply two 32-bit signed integers, writing the 64-bit result to the specified accumulator.

Description:

 ac = rs31..0 * rt31..0

The right-most 32-bit signed integer value in register rt is multiplied by the corresponding 32-bit signed integer value in register rs, to produce a 64-bit result that is written to the specified accumulator register.

The value of ac selects an accumulator numbered from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture.

In Release 6 of the MIPS Architecture, accumulators are eliminated from MIPS64.

No arithmetic exception occurs under any circumstances.

Restrictions:

On 64-bit processors, if the 32 most-significant bits of register rt or register rs do not contain sign bits (i.e., bits 31 through 63 equal) then the result of the operation is UNPREDICTABLE.

Operation:

 if (NotWordValue(GPR[rs]) or NotWordValue(GPR[rt])) then
   UNPREDICTABLE 
endif
temp63..0 = ((GPR[rs]31)32 || GPR[rs]31..0) * ((GPR[rt31)32 || GPR[rt]31..0)
( HI[ac]63..0 || LO[ac]63..0 ) = (temp63)32 || temp63..32 || (temp31)32 || temp31..0

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

In some processors the integer multiply operation may proceed asynchronously and allow other CPU instructions to execute before it is complete. An attempt to read LO or HI before the results are written interlocks until the results are ready. Asynchronous execution does not affect the program result, but offers an opportunity for performance improvement by scheduling the multiply so that other instructions can execute in parallel.

Programs that require overflow detection must check for it explicitly.

Where the size of the operands are known, software should place the shorter operand in register rt. This may reduce the latency of the instruction on those processors which implement data-dependent instruction latencies.

Encoding:

SPECIAL

000000

rs

rt

0

000

ac

0

MULTU

011001

6

5

5

3

2

5

6

Format:

MULTU ac, rs, rt 

MIPS32 pre-Release 6, MIPSDSP

Multiply Unsigned Word

Purpose:

Multiply Unsigned Word

To multiply 32-bit unsigned integers, writing the 64-bit result to the specified accumulator.

Description:

 ac = rs31..0 * rt31..0

The right-most 32-bit unsigned integer value in register rt is multiplied by the corresponding 32-bit unsigned integer value in register rs, to produce a 64-bit unsigned result that is written to the specified accumulator register.

The value of ac selects an accumulator numbered from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture.

In Release 6 of the MIPS Architecture, accumulators are eliminated from MIPS64.

No arithmetic exception occurs under any circumstances.

Restrictions:

On 64-bit processors, if the 32 most-significant bits of register rt or register rs do not contain sign bits (i.e., bits 31 through 63 equal) then the result of the operation is UNPREDICTABLE.

Operation:

 if NotWordValue(GPR[rs]) or NotWordValue(GPR[rt])) then
   UNPREDICTABLE 
endif
temp64..0 = ( 032 || GPR[rs]31..0 ) * ( 032 || GPR[rt]31..0 ) 
( HI[ac]63..0 || LO[ac]63..0 ) = (temp63)32 || temp63..32 || (temp31)32 || temp31..0

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

In some processors the integer multiply operation may proceed asynchronously and allow other CPU instructions to execute before it is complete. An attempt to read LO or HI before the results are written interlocks until the results are ready. Asynchronous execution does not affect the program result, but offers an opportunity for performance improvement by scheduling the multiply so that other instructions can execute in parallel.

Programs that require overflow detection must check for it explicitly.

Where the size of the operands are known, software should place the shorter operand in register rt. This may reduce the latency of the instruction on those processors which implement data-dependent instruction latencies.

Encoding:

SPECIAL3

011111

rs

rt

rd

MUL.PH

01100

ADDUH.QB

011000

SPECIAL3

011111

rs

rt

rd

MUL_S.PH

01110

ADDUH.QB

011000

6

5

5

5

5

6

Format:

MUL[_S].PH 

Multiply Vector Integer HalfWords to Same Size Products

MUL.PH    rd, rs, rt

MIPSDSP-R2

Multiply Vector Integer HalfWords to Same Size Products

MUL_S.PH  rd, rs, rt

MIPSDSP-R2

Multiply Vector Integer HalfWords to Same Size Products

Purpose:

Multiply Vector Integer HalfWords to Same Size Products

Multiply two vector halfword values.

Description:

rd = (rs31..16 * rt31..16) || (rs15..0 * rt15..0)

Each of the two integer halfword elements in register rs is multiplied by the corresponding integer halfword element in register rt to create a 32-bit signed integer intermediate result.

In the non-saturation version of the instruction, the 16 least-significant bits of each 32-bit intermediate result are written to the corresponding vector element in destination register rd.

In the saturating version of the instruction, intermediate results that cannot be represented in 16 bits are clipped to either the maximum positive 16-bit value (0x7FFF hexadecimal) or the minimum negative 16-bit value (0x8000 hexadecimal), depending on the sign of the intermediate result. The saturated results are then written to the destination register.

To stay compliant with the base architecture, this instruction leaves the base HI/LO pair (accumulator ac0) UNPREDICTABLE after the operation completes. The other DSP Module accumulators, ac1, ac2, and ac3, are unchanged.

In the saturating instruction variant, if either multiplication results in an overflow or underflow, the instruction writes a 1 to bit 21 in the ouflag field in the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

MUL.PH:
   tempB31..0 = MultiplyI16I16( GPR[rs]31..16, GPR[rt]31..16 )
   tempA31..0 = MultiplyI16I16( GPR[rs]15..0, GPR[rt]15..0 )
   GPR[rd]..0 = tempB15..0 || tempA15..0 
   HI..0 = UNPREDICTABLE
   LO..0 = UNPREDICTABLE
MUL_S.PH:
   tempB31..0 = sat16MultiplyI16I16( GPR[rs]31..16, GPR[rt]31..16 )
   tempA31..0 = sat16MultiplyI16I16( GPR[rs]15..0, GPR[rt]15..0 )
   GPR[rd]..0 = tempB15..0 || tempA15..0 
   HI..0 = UNPREDICTABLE
   LO..0 = UNPREDICTABLE
function MultiplyI16I16( a15..0, b15..0 ) 
   temp31..0 = a15..0 * b15..0
   if ( temp31..0 > 0x7FFF ) or ( temp31..0 < 0xFFFF8000 ) then
         DSPControlouflag:21 = 1
   endif
   return temp15..0
endfucntion MultiplyI16I16
function satMultiplyI16I16( a15..0, b15..0 ) 
   temp31..0 = a15..0 * b15..0
   if ( temp31..0 > 0x7FFF ) then
      temp31..0 = 0x00007FFF
      DSPControlouflag:21 = 1
   else
      if ( temp31..0 < 0xFFFF8000 ) then
         temp31..0 = 0xFFFF8000
          DSPControlouflag:21 = 1
      endif
   endif
   return temp15..0
endfucntion satMultiplyI16I16

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

The base MIPS64 architecture states that upon the after a GPR-targeting multiply instruction such as MUL, the contents of HI and LO are UNPREDICTABLE. To stay compliant with the base architecture, this multiply instruction states the same requirement. But this requirement does not apply to the new accumulators ac1-ac3 and hence a programmer must save the value in ac0 (which is the same as HI and LO) across a GPR-targeting multiply instruction, it needed, while the values in ac1-ac3 do not need to be saved.

Encoding:

SPECIAL3

011111

rs

rt

rd

PACKRL.PH

01110

CMPU.EQ.QB

010001

6

5

5

5

5

6

Format:

PACKRL.PH rd, rs, rt

MIPSDSP

Pack a Vector of Halfwords from Vector Halfword Sources

Purpose:

Pack a Vector of Halfwords from Vector Halfword Sources

Pick two elements for a halfword vector using the right halfword and left halfword respectively from the two source registers.

Description:

rd = sign_extend(rs15..0 || rt31..16)

The right-most halfword element from register rs and the left halfword from the two right-most halfwords in register

rt are packed into the two right-most halfword positions of the destination register rd.

The sign of the left-most halfword result is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = GPR[rs]15..0
tempA15..0 = GPR[rt]31..16
GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

PICK.PH

01011

CMPU.EQ.QB

010001

6

5

5

5

5

6

Format:

PICK.PH rd, rs, rt

MIPSDSP

Pick a Vector of Halfword Values Based on Condition Code Bits

Purpose:

Pick a Vector of Halfword Values Based on Condition Code Bits

Select two halfword elements from either of two source registers based on condition code bits, writing the selected elements to the destination register.

Description:

rd = sign_extend(pick(cc25,rs31..16,rt31..16) || pick(cc24,rs15..0,rt15..0))

The two right-most condition code bits in the DSPControl register are used to select halfword values from the corresponding element of either source register rs or source register rt. If the value of the corresponding condition code bit is 1, then the halfword value is selected from register rs; otherwise, it is selected from rt. The selected halfwords are written to the destination register rd.

The sign of the left-most halfword result is sign-extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = ( DSPControlccond:25 = 1 ? GPR[rs]31..16 : GPR[rt]31..16 )
tempA15..0 = ( DSPControlccond:24 = 1 ? GPR[rs]15..0 : GPR[rt]15..0 )
GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

PICK.QB

00011

CMPU.EQ.QB

010001

6

5

5

5

5

6

Format:

PICK.QB rd, rs, rt

MIPSDSP

Pick a Vector of Byte Values Based on Condition Code Bits

Purpose:

Pick a Vector of Byte Values Based on Condition Code Bits

Select four byte elements from either of two source registers based on condition code bits, writing the selected elements to the destination register.

Description:

rd = sign_extend(pick(cc27,rs31..24,rt31..24) || pick(cc26,rs23..16,rt23..16) || pick(cc25,rs15..8,rt15..8) || pick(cc24,rs7..0,rt7..0))

Four of the eight condition code bits in the DSPControl register are used to select byte values from the corresponding byte element of either source register rs or source register rt. If the value of the corresponding condition code bit is 1, then the byte value is selected from register rs; otherwise, it is selected from rt. The selected bytes are written to the destination register rd.

The sign of the left-most selected byte is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempD7..0 = ( DSPControlccond:27 = 1 ? GPR[rs]31..24 : GPR[rt]31..24 )
tempC7..0 = ( DSPControlccond:26 = 1 ? GPR[rs]23..16 : GPR[rt]23..16 )
tempB7..0 = ( DSPControlccond:25 = 1 ? GPR[rs]15..8 : GPR[rt]15..8 )
tempA7..0 = ( DSPControlccond:24 = 1 ? GPR[rs]7..0 : GPR[rt]7..0 )
GPR[rd]63..0 = (tempD7)32 || tempD7..0|| tempC7..0 || tempB7..0 || tempA7..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

00000

rt

rd

PRECEQ.W.PHL

01100

ABSQ_S.PH

010010

6

5

5

5

5

6

Format:

PRECEQ.W.PHL rd, rt

MIPSDSP

Precision Expand Fractional Halfword to Fractional Word Value

Purpose:

Precision Expand Fractional Halfword to Fractional Word Value

Expand the precision of a Q15 fractional value taken from the left element of a paired halfword vector to create a Q31 fractional word value.

Description:

rd = sign_extend(expand_prec(rt31..16))

The left Q15 fractional halfword value from the two right-most halfwords in register rt is expanded to a Q31 fractional value, sign-extended to 64 bits, and written to destination register rd. The precision expansion is achieved by appending 16 least-significant zero bits to the original halfword value to generate the 32-bit fractional value.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

temp31..0 = GPR[rt]31..16 || 016
GPR[rd]63..0 = (temp31)32 || temp31..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

00000

rt

rd

PRECEQ.W.PHR

01101

ABSQ_S.PH

010010

6

5

5

5

5

6

Format:

PRECEQ.W.PHR rd, rt

MIPSDSP

Precision Expand Fractional Halfword to Fractional Word Value

Purpose:

Precision Expand Fractional Halfword to Fractional Word Value

Expand the precision of a Q15 fractional value taken from the right element of a paired halfword vector to create a

Q31 fractional word value.

Description:

rd = sign_extend(expand_prec(rt15..0))

The right Q15 fractional halfword value from the two right-most halfwords in register rt is expanded to a Q31 fractional value, sign-extended to 64 bits, and written to destination register rd. The precision expansion is achieved by appending 16 least-significant zero bits to the original halfword value to generate the 32-bit fractional value.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

temp31..0 = GPR[rt]15..0 || 016
GPR[rd]63..0 = (temp31)32 || temp31..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

00000

rt

rd

PRECEQU.PH.QBLA

00110

ABSQ_S.PH

010010

6

5

5

5

5

6

Format:

PRECEQU.PH.QBLA rd, rt

MIPSDSP

Precision Expand two Unsigned Bytes to Fractional Halfword Values

Purpose:

Precision Expand two Unsigned Bytes to Fractional Halfword Values

Expand the precision of two unsigned byte values taken from the two left-alternate aligned elements of a quad byte vector to create two Q15 fractional halfword values.

Description:

rd = sign_extend(expand_prec(rt31..24) || expand_prec(rt15..8))

The two left-alternate aligned unsigned integer byte values from the four right-most byte elements in register rt are expanded to create two Q15 fractional values that are then written to destination register rd. The precision expansion is achieved by pre-pending a single zero bit (for positive sign) to the original byte value and appending seven leastsignificant zeros to generate each 16-bit fractional value.

The sign of the left-most result is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = 01 || GPR[rt]31..24 || 07 
tempA15..0 = 01 || GPR[rt]15..8 || 07 
GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

00000

rt

rd

PRECEQU.PH.QBL

00100

ABSQ_S.PH

010010

6

5

5

5

5

6

Format:

PRECEQU.PH.QBL rd, rt

MIPSDSP

Precision Expand two Unsigned Bytes to Fractional Halfword Values

Purpose:

Precision Expand two Unsigned Bytes to Fractional Halfword Values

Expand the precision of two unsigned byte values taken from the two left-most elements of a quad byte vector to create two Q15 fractional halfword values.

Description:

rd = sign_extend(expand_prec(rt31..24) || expand_prec(rt23..16))

The two left-most unsigned integer byte values from the four right-most byte elements in register rt are expanded to create two Q15 fractional values that are then written to destination register rd. The precision expansion is achieved by pre-pending a single zero bit (for positive sign) to the original byte value and appending seven least-significant zeros to generate each 16-bit fractional value.

Bit 31 of the result is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = 01 || GPR[rt]31..24 || 07 
tempA15..0 = 01 || GPR[rt]23..16 || 07 
GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

00000

rt

rd

PRECEQU.PH.QBRA

00111

ABSQ_S.PH

010010

6

5

5

5

5

6

Format:

PRECEQU.PH.QBRA rd, rt

MIPSDSP

Precision Expand two Unsigned Bytes to Fractional Halfword Values

Purpose:

Precision Expand two Unsigned Bytes to Fractional Halfword Values

Expand the precision of two unsigned byte values taken from the two right-alternate aligned elements of a quad byte vector to create two Q15 fractional halfword values.

Description:

rd = sign_extend(expand_prec(rt23..16) || expand_prec(rt7..0))

The two right-alternate aligned unsigned integer byte values from the four right-most byte elements in register rt are expanded to create two Q15 fractional values that are then written to destination register rd. The precision expansion is achieved by pre-pending a single zero bit (for positive sign) to the original byte value and appending seven leastsignificant zeros to generate each 16-bit fractional value.

The sign of the left-most result is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = 01 || GPR[rt]23..16 || 07 
tempA15..0 = 01 || GPR[rt]7..0 || 07 
GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

00000

rt

rd

PRECEQU.PH.QBR

00101

ABSQ_S.PH

010010

6

5

5

5

5

6

Format:

PRECEQU.PH.QBR rd, rt

MIPSDSP

Precision Expand two Unsigned Bytes to Fractional Halfword Values

Purpose:

Precision Expand two Unsigned Bytes to Fractional Halfword Values

Expand the precision of two unsigned byte values taken from the two right-most elements of a quad byte vector to create two Q15 fractional halfword values.

Description:

rd = sign_extend(expand_prec(rt15..8) || expand_prec(rt7..0))

The two right-most unsigned integer byte values from the four right-most byte elements in register rt are expanded to create two Q15 fractional values that are then written to destination register rd. The precision expansion is achieved by pre-pending a single zero bit (for positive sign) to the original byte value and appending seven least-significant zeros to generate each 16-bit fractional value.

Bit 31 of the result is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = 01 || GPR[rt]15..8 || 07 
tempA15..0 = 01 || GPR[rt]7..0 || 07 
GPR[rd]63..0 = (tempB15) || tempB15..0 || tempA15..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

00000

rt

rd

PRECEU.PH.QBLA

11110

ABSQ_S.PH

010010

6

5

5

5

5

6

Format:

PRECEU.PH.QBLA rd, rt

MIPSDSP

Precision Expand Two Unsigned Bytes to Unsigned Halfword Values

Purpose:

Precision Expand Two Unsigned Bytes to Unsigned Halfword Values

Expand the precision of two unsigned integer byte values taken from the two left-alternate aligned positions of a quad byte vector to create four unsigned halfword values.

Description:

rd = sign_extend(expand_prec8u16(rt31..24) || expand_prec8u16(rt15..8))

The two left-alternate aligned unsigned integer byte values from the four right-most byte elements in register rt are each expanded to unsigned halfword values and written to destination register rd. The precision expansion is achieved by pre-pending eight most-significant zero bits to the original byte value to generate each 16 bit unsigned halfword value.

The sign of the left-most result is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = 08 || GPR[rt]31..24
tempA15..0 = 08 || GPR[rt]15..8
GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

00000

rt

rd

PRECEU.PH.QBL

11100

ABSQ_S.PH

010010

6

5

5

5

5

6

Format:

PRECEU.PH.QBL rd, rt

MIPSDSP

Precision Expand Two Unsigned Bytes to Unsigned Halfword Values

Purpose:

Precision Expand Two Unsigned Bytes to Unsigned Halfword Values

Expand the precision of two unsigned byte values taken from the two left-most elements of a quad byte vector to create two unsigned halfword values.

Description:

rd = sign_extend(expand_prec8u16(rt31..24) || expand_prec8u16(rt23..16))

The two left-most unsigned integer byte values from the four right-most byte elements in register rt are expanded to create two unsigned halfword values that are then written to destination register rd. The precision expansion is achieved by pre-pending eight most-significant zeros to each original value to generate each 16 bit unsigned value.

Bit 31 of the result is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = 08 || GPR[rt]31..24
tempA15..0 = 08 || GPR[rt]23..16
GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

00000

rt

rd

PRECEU.PH.QBRA

11111

ABSQ_S.PH

010010

6

5

5

5

5

6

Format:

PRECEU.PH.QBRA rd, rt

MIPSDSP

Precision Expand Two Unsigned Bytes to Unsigned Halfword Values

Purpose:

Precision Expand Two Unsigned Bytes to Unsigned Halfword Values

Expand the precision of two unsigned byte values taken from the two right-alternate aligned positions of a quad byte vector to create two unsigned halfword values.

Description:

rd = sign_extend(expand_prec8u16(rt23..16) || expand_prec8u16(rt7..0))

The two right-alternate aligned unsigned integer byte values from the four right-most byte elements in register rt are each expanded to unsigned halfword values and written to destination register rd. The precision expansion is achieved by pre-pending eight most-significant zero bits to the original byte value to generate each 16 bit unsigned halfword value.

The sign of the left-most result is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = 08 || GPR[rt]23..16
tempA15..0 = 08 || GPR[rt]7..0
GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

00000

rt

rd

PRECEU.PH.QBR

11101

ABSQ_S.PH

010010

6

5

5

5

5

6

Format:

PRECEU.PH.QBR rd, rt

MIPSDSP

Precision Expand two Unsigned Bytes to Unsigned Halfword Values

Purpose:

Precision Expand two Unsigned Bytes to Unsigned Halfword Values

Expand the precision of two unsigned integer byte values taken from the two right-most elements of a quad byte vector to create two unsigned halfword values.

Description:

rd = sign_extend(expand_prec8u16(rt15..8) || expand_prec8u16(rt7..0))

The two right-most unsigned integer byte values from the four right-most byte elements in register rt are expanded to create two unsigned halfword values that are then written to destination register rd. The precision expansion is achieved by pre-pending eight most-significant zero bits to each original value to generate each 16 bit halfword value.

Bit 31 of the result is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = 08 || GPR[rt]15..8
tempA15..0 = 08 || GPR[rt]7..0
GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

PRECR.QB.PH

01101

CMPU.EQ.QB

010001

6

5

5

5

5

6

Format:

PRECR.QB.PH rd, rs, rt

MIPSDSP-R2

Precision Reduce Four Integer Halfwords to Four Bytes

Purpose:

Precision Reduce Four Integer Halfwords to Four Bytes

Reduce the precision of four integer halfwords to four byte values.

Description:

rd = sign_extend(rs23..16 || rs7..0 || rt23..16 || rt7..0)

The 8 least-significant bits from each of the two right-most integer halfword values in registers rs and rt are taken to produce four byte-sized results that are written to the four right-most byte elements in destination register rd. The two bytes values obtained from rs are written to the two left-most destination byte elements, and the two bytes obtained from rt are written to the two right-most destination byte elements.

The sign of the left-most byte result is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempD7..0 = GPR[rs]23..16
tempC7..0 = GPR[rs]7..0
tempB7..0 = GPR[rt]23..16
tempA7..0 = GPR[rt]7..0
GPR[rd]63..0 = (tempD7)32 || tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

PRECRQ.PH.W

10100

CMPU.EQ.QB

010001

6

5

5

5

5

6

Format:

PRECRQ.PH.W rd, rs, rt

MIPSDSP

Precision Reduce Fractional Words to Fractional Halfwords

Purpose:

Precision Reduce Fractional Words to Fractional Halfwords

Reduce the precision of two fractional words to produce two fractional halfword values.

Description:

rd = sign_extend(rt31..16 || rs31..16)

The 16 most-significant bits from each of the right-most Q31 fractional word values in registers rs and rt are written to destination register rd, creating a vector of two Q15 fractional values. The right-most fractional word from the rs register is used to create the left-most Q15 fractional value in rd, and the right-most fractional word from the rt register is used to create the right-most Q15 fractional value.

The sign of the left-most halfword result is sign-extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = GPR[rs]31..16
tempA15..0 = GPR[rt]31..16
GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

PRECRQ.QB.PH

01100

CMPU.EQ.QB

010001

6

5

5

5

5

6

Format:

PRECRQ.QB.PH rd, rs, rt

MIPSDSP

Precision Reduce Four Fractional Halfwords to Four Bytes

Purpose:

Precision Reduce Four Fractional Halfwords to Four Bytes

Reduce the precision of four fractional halfwords to four byte values.

Description:

rd = sign_extend(rs31..24 || rs15..8 || rt31..24 || rt15..8)

The two right-most Q15 fractional values in each of registers rs and rt are truncated by dropping the eight least significant bits from each value to produce four fractional byte values. The four fractional byte values are written to the four right-most byte elements of destination register rd. The two values obtained from register rt are placed in the two right-most byte positions in the destination register, and the two values obtained from register rs are placed in the two remaining byte positions.

The sign of the left-most result is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempD7..0 = GPR[rs]31..24
tempC7..0 = GPR[rs]15..8
tempB7..0 = GPR[rt]31..24
tempA7..0 = GPR[rt]15..8
GPR[rd]63..0 = (tempD7)32 || tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

PRECRQU_S.QB.PH

01111

CMPU.EQ.QB

010001

6

5

5

5

5

6

Format:

PRECRQU_S.QB.PH rd, rs, rt

MIPSDSP

Precision Reduce Fractional Halfwords to Unsigned Bytes With Saturation

Purpose:

Precision Reduce Fractional Halfwords to Unsigned Bytes With Saturation

Reduce the precision of four fractional halfwords with saturation to produce four unsigned byte values, with saturation.

Description:

rd = sign_extend(sat(reduce_prec(rs31..16)) || sat(reduce_prec(rs15..0)) || sat(reduce_prec(rt31..16)) || sat(reduce_prec(rt15..0)))

The four right-most Q15 fractional halfwords from registers rs and rt are used to create four unsigned byte values that are written to corresponding elements of destination register rd. The two right-most halfwords from the rs register and the two right-most halfwords from the rt register are used to create the four unsigned byte values.

Each unsigned byte value is created from the Q15 fractional halfword input value after first examining the sign and magnitude of the halfword. If the sign of the halfword value is positive and the value is greater than 0x7F80 hexadecimal, the result is clamped to the maximum positive 8-bit value (255 decimal, 0xFF hexadecimal). If the sign of the halfword value is negative, the result is clamped to the minimum positive 8-bit value (0 decimal, 0x00 hexadecimal).

Otherwise, the sign bit is discarded from the input and the result is taken from the eight most-significant bits that remain.

If clamping was needed to produce any of the unsigned output values, bit 22 of the DSPControl register is set to 1.

The sign of the left-most byte result is extended into the 32 most-significant bits of destination register rd.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempD7..0 = sat8ReducePrecision( GPR[rs]31..16 )
tempC7..0 = sat8ReducePrecision( GPR[rs]15..0 )
tempB7..0 = sat8ReducePrecision( GPR[rt]31..16 )
tempA7..0 = sat8ReducePrecision( GPR[rt]15..0 )
GPR[rd]63..0 = (tempD7)32 || tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0
function sat8ReducePrecision( a15..0 )
   sign = a15
   mag14..0 = a14..0
   if ( sign = 0 ) then
      if ( mag14..0 > 0x7F80 ) then
         temp7..0 = 0xFF
          DSPControlouflag:22 = 1
      else
         temp7..0 = mag14..7
      endif
   else
      temp7..0 = 0x00
      DSPControlouflag:22 = 1
   endif
   return temp7..0
endfunction sat8ReducePrecision

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

PRECRQ_RS.PH.W

10101

CMPU.EQ.QB

010001

6

5

5

5

5

6

Format:

PRECRQ_RS.PH.W rd, rs, rt

MIPSDSP

Precision Reduce Fractional Words to Halfwords With Rounding and Saturation

Purpose:

Precision Reduce Fractional Words to Halfwords With Rounding and Saturation

Reduce the precision of two fractional words to produce two fractional halfword values, with rounding and saturation.

Description:

rd = sign_extend(truncQ15SatRound(rs31..0) || truncQ15SatRound(rt31..0))

The two right-most Q31 fractional word values in each of registers rs and rt are used to create two Q15 fractional halfword values that are written to the two right-most halfword elements in destination register rd. The right-most fractional word from the rs register is used to create the left-most Q15 fractional halfword result in rd, and the rightmost fractional word from the rt register is used to create the right-most halfword value.

Each input Q31 fractional value is rounded and saturated before being truncated to create the Q15 fractional halfword result. First, the value 0x00008000 is added to the input Q31 value to round even, creating an interim rounded result.

If this addition causes overflow, the interim rounded result is saturated to the maximum Q31 value (0x7FFFFFFF hexadecimal). Then, the 16 least-significant bits of the interim rounded and saturated result are discarded and the 16 most-significant bits are written to the destination register in the appropriate position.

The sign of the left-most halfword result is sign-extended into the 32 most-significant bits of the destination register.

If either of the rounding operations results in overflow and saturation, a 1 is written to bit 22 in the DSPControl register within the ouflag field.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = trunc16Sat16Round( GPR[rs]31..0 )
tempA15..0 = trunc16Sat16Round( GPR[rt]31..0 )
GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
function trunc16Sat16Round( a31..0 )
   temp32..0 = ( a31 || a31..0 ) + 0x00008000
   if ( temp32 != temp31 ) then
      temp32..0 = 0 || 0x7FFFFFFF
      DSPControlouflag:22 = 1
   endif
   return temp31..16
endfunction trunc16Sat16Round

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

sa

PRECR_SRA.PH.W

11110

CMPU.EQ.QB

010001

SPECIAL3

011111

rs

rt

sa

PRECR_SRA_R.PH.W

11111

CMPU.EQ.QB

010001

6

5

5

5

5

6

Format:

PRECR_SRA[_R].PH.W 

Precision Reduce Two Integer Words to Halfwords after a Right Shift

PRECR_SRA.PH.W    rt, rs, sa

MIPSDSP-R2

Precision Reduce Two Integer Words to Halfwords after a Right Shift

PRECR_SRA_R.PH.W   rt, rs, sa

MIPSDSP-R2

Precision Reduce Two Integer Words to Halfwords after a Right Shift

Purpose:

Precision Reduce Two Integer Words to Halfwords after a Right Shift

Do an arithmetic right shift of two integer words with optional rounding, and then reduce the precision to halfwords.

Description:

rt = sign_extend((round(rt>>shift))15..0 || (round(rs>>shift))15..0)

The two right-most words in registers rs and rt are right shifted arithmetically by the specified shift amount sa to create interim results. The 16 least-significant bits of each interim result are then written to the corresponding elements of destination register rt.

In the rounding version of the instruction, a value of 1 is added at the most-significant discarded bit position after the shift is performed. The 16 least-significant bits of each interim result are then written to the corresponding elements of destination register rt.

The shift amount sa is interpreted as a five-bit unsigned integer taking values between 0 and 31.

The sign of the left-most halfword result is extended into the 32 most-significant bits of destination register rt.

This instruction does not write any bits of the ouflag field in the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

PRECR_SRA.PH.W:
   if (sa4..0 = 0) then
      tempB15..0 = GPR[rt]15..0
      tempA15..0 = GPR[rs]15..0
   else
      tempB15..0 = ( (GPR[rt]31)sa || GPR[rt]31..sa )
      tempA15..0 = ( (GPR[rs]31)sa || GPR[rs]31..sa )
   endif
   GPR[rt]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
PRECR_SRA_R.PH.W:
   if (sa4..0 = 0) then
      tempB16..0 = ( GPR[rt]15..0 || 0 )
      tempA16..0 = ( GPR[rs]15..0 || 0 )
   else
      tempB32..0 = ( (GPR[rt]31)sa || GPR[rt]31..sa-1 ) + 1
      tempA32..0 = ( (GPR[rs]31)sa || GPR[rs]31..sa-1 ) + 1
   endif
   GPR[rt]63..0 = (tempB16)32 || tempB16..1 || tempA16..1

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

sa

PREPEND

00001

APPEND

110001

6

5

5

5

5

6

Format:

PREPEND rt, rs, sa

MIPSDSP-R2

Right Shift and Prepend Bits to the MSB

Purpose:

Right Shift and Prepend Bits to the MSB

Logically right-shift the first source register, replacing the bits emptied by the shift with bits from the source register.

Description:

rt = sign_extend(rssa-1..0 || (rt >> sa))

The right-most word value in register rt is logically right-shifted by the specified shift amount sa, and sa bits from the least-significant positions of register rs are written into the sa most-significant bits emptied by the shift. The result is then sign-extended to 64 bits and written to destination register rt.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

if ( sa4..0 = 0 ) then
   temp31..0 = GPR[rt]31..0 
else
   temp31..0 = ( GPR[rs]sa-1..0 || GPR[rt]31..sa )
endif
GPR[rt]63..0 = (temp31)32 || temp31..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

0

00000

rd

RADDU.W.QB

10100

ADDU.QB

010000

6

5

5

5

5

6

Format:

RADDU.W.QB rd, rs

MIPSDSP

Unsigned Reduction Add Vector Quad Bytes

Purpose:

Unsigned Reduction Add Vector Quad Bytes

Reduction add of four unsigned byte values in a vector register to produce an unsigned word result.

Description:

rd = zero_extend(rs31..24 + rs23..16 + rs15..8 + rs7..0)

The four right-most unsigned byte elements in register rs are added together as unsigned 8-bit values, and the result is zero extended to a doubleword and written to register rd.

Restrictions:

No data-dependent exceptions are possible.

The operands must be in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

temp9..0 = ( 02 || GPR[rs]31..24 ) + ( 02 || GPR[rs]23..16 ) + ( 02 || GPR[rs]15..8 ) + ( 02 || GPR[rs]7..0 )
GPR[rd]63..0 = 0(GPRLEN-10) || temp9..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

mask

rd

RDDSP

10010

EXTR.W

111000

6

10

5

5

6

Format:

RDDSP rd, mask

MIPSDSP

Read DSPControl Register Fields to a GPR

Purpose:

Read DSPControl Register Fields to a GPR

To copy selected fields from the special-purpose DSPControl register to the specified GPR.

Description:

rd = select(mask, DSPControl)

Selected fields in the special register DSPControl are copied into the corresponding bits of destination register rd.

Each of bits 0 through 5 of the mask operand corresponds to a specific field in the DSPControl register. A mask bit value of 1 indicates that the bits from the corresponding field in DSPControl will be copied into the same bit positions in register rd, and a mask bit value of 0 indicates that the corresponding bit positions in rd will be set to zero. Bits 6 through 9 of the mask operand are ignored.

The table below shows the correspondence between the bits in the mask operand and the fields in the DSPControl register; mask bit 0 is the least-significant bit in mask.

ccond

ouflag

0

EFI

C

scount

pos

4

3

5

2

1

0

For example, to copy only the bits from the scount field in DSPControl, the value of the mask operand used will be 2 decimal (0x02 hexadecimal). After execution of the instruction, bits 7 through 12 of register rd will have the value of bits 7 through 12 from the scount field in DSPControl. The remaining bits in register rd will be set to zero.

The one-operand version of the instruction provides a convenient assembly idiom that allows the programmer to read all fields in the DSPControl register into the destination register, i.e., it is equivalent to specifying a mask value of 31 decimal (0x1F hexadecimal).

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

temp63..0 = 064
if ( mask0 = 1 ) then
   temp6..0 = DSPControlpos:6..0
endif
if ( mask1 = 1 ) then
   temp12..7 = DSPControlscount:12..7
endif
if ( mask2 = 1 ) then
   temp13 = DSPControlc:13
endif
if ( mask3 = 1 ) then
   temp23..16 = DSPControlouflag:23..16
endif
if ( mask4 = 1 ) then
   temp31..24 = DSPControlccond:31..24
endif
if ( mask5 = 1 ) then
   temp14 = DSPControlefi:14
endif
GPR[rd]63..0 = temp63..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

immediate

rd

REPL.PH

01010

ABSQ_S.PH

010010

6

10

5

5

6

Format:

REPL.PH  rd, immediate

MIPSDSP

Replicate Immediate Integer into all Vector Element Positions

Purpose:

Replicate Immediate Integer into all Vector Element Positions

Replicate a sign-extended, 10-bit signed immediate integer value into the two right-most halfwords in a halfword vector.

Description:

rd = sign_extend(sign_extend(immediate) || sign_extend(immediate))

The specified 10-bit signed immediate integer value is sign-extended to 16 bits and replicated into the two right-most halfword positions in destination register rd.

The sign of the immediate value is sign-extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

temp15..0 = (immediate9)6 || immediate9..0
GPR[rd]63..0 = (temp15..0)32 || temp15..0 || temp15..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

micro

SPECIAL3

011111

0

00

immediate

rd

REPL.QB

00010

ABSQ_S.PH

010010

6

2

8

5

5

6

Format:

REPL.QB  rd, immediate

MIPSDSP

Replicate Immediate Integer into all Vector Element Positions

Purpose:

Replicate Immediate Integer into all Vector Element Positions

Replicate a immediate byte into all elements of a quad byte vector.

Description:

rd = sign_extend(immediate || immediate || immediate || immediate)

The specified 8-bit signed immediate value is replicated into the four right-most byte elements of destination register

rd.

The sign of the immediate value is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

temp7..0 = immediate7..0
GPR[rd]63..0 = (temp7)32 || temp7..0 || temp7..0 || temp7..0 || temp7..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

00000

rt

rd

REPLV.PH

01011

ABSQ_S.PH

010010

6

5

5

5

5

6

Format:

REPLV.PH  rd, rt

MIPSDSP

Replicate a Halfword into all Vector Element Positions

Purpose:

Replicate a Halfword into all Vector Element Positions

Replicate a variable halfword into the right-most elements of a halfword vector.

Description:

rd = sign_extend(rt15..0 || rt15..0)

The right-most halfword value in register rt is replicated into the two right-most halfword elements of destination register rd.

The sign of the source halfword is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

temp15..0 = GPR[rt]15..0
GPR[rd]63..0 = (temp15..0)32 || temp15..0 || temp15..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

00000

rt

rd

REPLV.QB

00011

ABSQ_S.PH

010010

6

5

5

5

5

6

Format:

REPLV.QB  rd, rt

MIPSDSP

Replicate Byte into all Vector Element Positions

Purpose:

Replicate Byte into all Vector Element Positions

Replicate a variable byte into all elements of a quad byte vector.

Description:

rd = sign_extend(rt7..0 || rt7..0 || rt7..0 || rt7..0)

The right-most byte value in register rt is replicated into the four right-most byte elements of destination register rd.

The sign of the source byte value is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

temp7..0 = GPR[rt]7..0
GPR[rd]63..0 = (temp7)32 || temp7..0 || temp7..0 || temp7..0 || temp7..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

shift

0

0000

0

000

ac

SHILO

11010

EXTR.W

111000

6

6

4

3

2

5

6

Format:

SHILO ac, shift

MIPSDSP

Shift an Accumulator Value Leaving the Result in the Same Accumulator

Purpose:

Shift an Accumulator Value Leaving the Result in the Same Accumulator

Shift the HI/LO paired value in a 64-bit accumulator either left or right, leaving the result in the same accumulator.

Description:

ac = (shift >= 0) ? (ac >> shift) : (ac << -shift)

The HI/LO register pair is treated as a single 64-bit accumulator that is shifted logically by shift bits, with the result of the shift written back to the source accumulator. The shift argument is a six-bit signed integer value: a positive argument results in a right shift of up to 31 bits, and a negative argument results in a left shift of up to 32 bits.

The value of ac can range from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

sign = shift5 
shift5..0 = ( sign = 0 ? shift5..0 : -shift5..0 )
if ( shift5..0 = 0 ) then
   temp63..0 = (HI[ac]31..0 || LO[ac]31..0)
else
   if (sign = 0) then
      temp63..0 = 0shift || (( HI[ac]31..0 || LO[ac]31..0 ) >> shift )
   else
      temp63..0 = (( HI[ac]31..0 || LO[ac]31..0 ) << shift ) || 0shift
   endif
endif
( HI[ac]63..0 || LO[ac]63..0 ) = (temp63)64 || temp63..32 || (temp63)64 || temp31..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

0

00000

0

000

ac

SHILOV

11011

EXTR.W

111000

6

5

5

3

2

5

6

Format:

SHILOV ac, rs

MIPSDSP

Variable Shift of Accumulator Value Leaving the Result in the Same Accumulator

Purpose:

Variable Shift of Accumulator Value Leaving the Result in the Same Accumulator

Shift the HI/LO paired value in an accumulator either left or right by the amount specified in a GPR, leaving the result in the same accumulator.

Description:

ac = ( GPR[rs]6..0 >= 0) ? (ac >> GPR[rs]6..0) : (ac << -GPR[rs]6..0)

The HI/LO register pair is treated as a single 64-bit accumulator that is shifted logically by shift bits, with the result of the shift written back to the source accumulator. The shift argument is provided by the six least-significant bits of register rs; the remaining bits of rs are ignored. The shift argument is interpreted as a six-bit signed integer: a positive argument results in a right shift of up to 31 bits, and a negative argument results in a left shift of up to 32 bits.

The value of ac can range from 0 to 3. When ac=0, this refers to the original HI/LO register pair of the MIPS64 architecture.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

sign = GPR[rs]5
shift5..0 = ( sign = 0 ? GPR[rs]5..0 : -GPR[rs]5..0 )
if ( shift5..0 = 0 ) then
   temp63..0 = ( HI[ac]31..0 || LO[ac]31..0 )
else
   if ( sign = 0 ) then
      temp63..0 = 0shift || (( HI[ac]31..0 || LO[ac]31..0 ) >> shift )
   else
      temp63..0 = (( HI[ac]31..0 || LO[ac]31..0 ) << shift ) || 0shift
   endif
endif
( HI[ac]63..0 || LO[ac]63..0 ) = (temp63)64 || temp63..32 || (temp63)64 || temp31..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

00

sa

rt

rd

SHLL.QB

00000

SHLL.QB

010011

6

2

3

5

5

5

6

Format:

SHLL.QB rd, rt, sa

MIPSDSP

Shift Left Logical Vector Quad Bytes

Purpose:

Shift Left Logical Vector Quad Bytes

Element-wise left shift of four independent bytes in a vector data type by a fixed number of bits.

Description:

rd = sign_extend((rt31..24 << sa) || (rt23..16 << sa) || (rt15..8 << sa) || (rt7..0 << sa))

The four right-most byte values in register rt are each independently shifted left by sa bits and the sa least significant bits of each value are set to zero. The four independent results are then written to the corresponding byte elements of destination register rd.

The sign of the left-most byte result is extended into the 32 most-significant bits of the destination register.

This instruction writes a 1 to bit 22 in the DSPControl register in the ouflag field if any of the left shift operations results in an overflow.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempD7..0 = shift8Left( GPR[rt]31..24, sa2..0 )
tempC7..0 = shift8Left( GPR[rt]23..16, sa2..0 )
tempB7..0 = shift8Left( GPR[rt]15..8, sa2..0 )
tempA7..0 = shift8Left( GPR[rt]7..0, sa2..0 )
GPR[rd]63..0 = (tempD7)32 || tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0
function shift8Left( a7..0, s2..0 )
   if ( s2..0 = 0 ) then
      temp7..0 = a7..0
   else
      sign = a7
      temp7..0 = ( a7-s..0 || 0s )
      discard7..0 = ( sign(8-s) || a6..6-(s-1) )
      if ( discard7..0 != 0x00 ) then
          DSPControlouflag:22 = 1
      endif
   endif
   return temp7..0
endfunction shift8Left

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

SHLLV.QB

00010

SHLL.QB

010011

6

5

5

5

5

6

Format:

SHLLV.QB rd, rt, rs

MIPSDSP

Shift Left Logical Variable Vector Quad Bytes

Purpose:

Shift Left Logical Variable Vector Quad Bytes

Element-wise left shift of four independent bytes in a vector data type by a variable number of bits.

Description:

rd = sign_extend((rt31..24 << rs2..0) || (rt23..16 << rs2..0) || (rt15..8 << rs2..0) || (rt7..0 << rs2..0))

The four right-most byte values in register rt are each independently shifted left by sa bits, inserting zeros into the least-significant bit positions emptied by the shift. The four independent results are then written to the corresponding byte elements of destination register rd.

The sign of the left-most byte result is extended into the 32 most-significant bits of the destination register.

The three least-significant bits of rs provide the shift value, interpreted as a three-bit unsigned integer; the remaining bits of rs are ignored.

This instruction writes a 1 to bit 22 in the DSPControl register in the ouflag field if any of the left shift operations results in an overflow.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempD7..0 = shift8Left( GPR[rt]31..24, GPR[rs]2..0 )
tempC7..0 = shift8Left( GPR[rt]23..16, GPR[rs]2..0 )
tempB7..0 = shift8Left( GPR[rt]15..8, GPR[rs]2..0 )
tempA7..0 = shift8Left( GPR[rt]7..0, GPR[rs]2..0 )
GPR[rd]63..0 = (tempD7)32 || tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

SHLLV.PH

01010

SHLL.QB

010011

SPECIAL3

011111

rs

rt

rd

SHLLV_S.PH

01110

SHLL.QB

010011

6

5

5

5

5

6

Format:

SHLLV[_S].PH 

Shift Left Logical Variable Vector Pair Halfwords

SHLLV.PH   rd, rt, rs

MIPSDSP

Shift Left Logical Variable Vector Pair Halfwords

SHLLV_S.PH rd, rt, rs

MIPSDSP

Shift Left Logical Variable Vector Pair Halfwords

Purpose:

Shift Left Logical Variable Vector Pair Halfwords

Element-wise left shift of the two right-most independent halfwords in a vector data type by a variable number of bits, with optional saturation.

Description:

rd = sign_extend(sat16(rt31..16 << rs3..0) || sat16(rt15..0 << rs3..0))

The two right-most halfword values in register rt are each independently shifted left by shift bits, inserting zeros into the least-significant bit positions emptied by the shift. In the saturating version of the instruction, if the shift results in an overflow the intermediate result is saturated to either the maximum positive or the minimum negative 16-bit value, depending on the sign of the original unshifted value. The two independent results are then written to the corresponding halfword elements of destination register rd.

The sign of the left-most halfword result is extended into the 32 most significant bits of destination register rd.

The four least-significant bits of rs provide the shift value, interpreted as a four-bit unsigned integer; the remaining bits of rs are ignored.

This instruction writes a 1 to bit 22 in the DSPControl register in the ouflag field if any of the left shift operations results in an overflow or saturation.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

SHLLV.PH:
   tempB15..0 = shift16Left( GPR[rt]31..16, GPR[rs]3..0 )
   tempA15..0 = shift16Left( GPR[rt]15..0, GPR[rs]3..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
SHLLV_S.PH:
   tempB15..0 = sat16ShiftLeft( GPR[rt]31..16, GPR[rs]3..0 )
   tempA15..0 = sat16ShiftLeft( GPR[rt]15..0, GPR[rs]3..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

SHLLV_S.W

10110

SHLL.QB

010011

6

5

5

5

5

6

Format:

SHLLV_S.W rd, rt, rs

MIPSDSP

Shift Left Logical Variable Vector Word

Purpose:

Shift Left Logical Variable Vector Word

A left shift of the right-most word in a vector data type by a variable number of bits, with optional saturation.

Description:

rd = sign_extend(sat32(rt31..0 << rs4..0))

The right-most word element in register rt is shifted left by shift bits, inserting zeros into the least-significant bit positions emptied by the shift. If the shift results in an overflow the intermediate result is saturated to either the maximum positive or the minimum negative 32-bit value, depending on the sign of the original unshifted value.

The shifted result is then sign-extended to 64 bits and written to destination register rd.

The five least-significant bits of rs are used as the shift value, interpreted as a five-bit unsigned integer; the remaining bits of rs are ignored.

This instruction writes a 1 to bit 22 in the DSPControl register in the ouflag field if either of the left shift operations results in an overflow or saturation.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

temp31..0 = sat32ShiftLeft( GPR[rt]31..0, GPR[rs]4..0 )
GPR[rd]63..0 = (temp31)32 || temp31..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

sa

rt

rd

SHLL.PH

01000

SHLL.QB

010011

SPECIAL3

011111

0

sa

rt

rd

SHLL_S.PH

01100

SHLL.QB

010011

6

1

4

5

5

5

6

Format:

SHLL[_S].PH 

Shift Left Logical Vector Pair Halfwords

SHLL.PH   rd, rt, sa

MIPSDSP

Shift Left Logical Vector Pair Halfwords

SHLL_S.PH rd, rt, sa

MIPSDSP

Shift Left Logical Vector Pair Halfwords

Purpose:

Shift Left Logical Vector Pair Halfwords

Element-wise shift of two independent halfwords in a vector data type by a fixed number of bits, with optional saturation.

Description:

rd = sign_extend(sat16(rt31..16 << sa) || (rt15..0 << sa))

The two right-most halfword values in register rt are each independently shifted left, inserting zeros into the least-significant bit positions emptied by the shift. In the saturating version of the instruction, if the shift results in an overflow the intermediate result is saturated to either the maximum positive or the minimum negative 16-bit value, depending on the sign of the original unshifted value. The two independent results are then written to the corresponding halfword elements of destination register rd.

The sign of the left-most halfword result is extended into the 32 most-significant bits of the destination register.

This instruction writes a 1 to bit 22 in the DSPControl register in the ouflag field if any of the left shift operations results in an overflow or saturation.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

SHLL.PH:
   tempB15..0 = shift16Left( GPR[rt]31..16, sa )
   tempA15..0 = shift16Left( GPR[rt]15..0, sa )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
SHLL_S.PH:
   tempB15..0 = sat16ShiftLeft( GPR[rt]31..16, sa )
   tempA15..0 = sat16ShiftLeft( GPR[rt]15..0, sa )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
function shift16Left( a15..0, s3..0 )
   if ( s3..0 = 0 ) then
      temp15..0 = a15..0
   else
      sign = a15
      temp15..0 = ( a15-s..0 || 0s )
      discard15..0 = ( sign(16-s) || a14..14-(s-1) )
      if (( discard15..0 != 0x0000 ) and ( discard15..0 != 0xFFFF )) then
          DSPControlouflag:22 = 1
      endif
   endif
   return temp15..0
endfunction shift16Left
function sat16ShiftLeft( a15..0, s3..0 )
   if ( s3..0 = 0 ) then
      temp15..0 = a15..0
   else
      sign = a15
      temp15..0 = ( a15-s..0 || 0s )
      discard15..0 = ( sign(16-s) || a14..14-(s-1) )
      if (( discard15..0 != 0x0000 ) and ( discard15..0 != 0xFFFF )) then
          temp15..0 = ( sign = 0 ? 0x7FFF : 0x8000 )
          DSPControlouflag:22 = 1
      endif
   endif
   return temp15..0
endfunction sat16ShiftLeft

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

sa

rt

rd

SHLL_S.W

10100

SHLL.QB

010011

6

5

5

5

5

6

Format:

SHLL_S.W rd, rt, sa

MIPSDSP

Shift Left Logical Word with Saturation

Purpose:

Shift Left Logical Word with Saturation

To execute a left shift of a word with saturation by a fixed number of bits.

Description:

rd = sign_extend(sat32(rt << sa))

The right-most 32-bit word in register rt is shifted left by sa bits, with zeros inserted into the bit positions emptied by the shift. If the shift results in a signed overflow, the shifted result is saturated to either the maximum positive (hexadecimal 0x7FFFFFFF) or minimum negative (hexadecimal 0x80000000) 32-bit value, depending on the sign of the original unshifted value. The shifted result is then sign-extended to 64 bits and written to destination register rd.

The instruction's sa field specifies the shift value, interpreted as a five-bit unsigned integer.

If the shift operation results in an overflow and saturation, this instruction writes a 1 to bit 22 of the DSPControl register within the ouflag field.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

temp31..0 = sat32ShiftLeft( GPR[rt]31..0, sa4..0 )
GPR[rd]63..0 = (temp31)32 || temp31..0
function sat32ShiftLeft( a13..0, s4..0 )
   if ( s = 0 ) then
      temp31..0 = a
   else
      sign = a31
      temp31..0 = ( a31-s..0 || 0s )
      discard31..0 = ( sign(32-s) || a30..30-(s-1) )
      if (( discard31..0 != 0x00000000 ) and ( discard31..0 != 0xFFFFFFFF )) then
          temp31..0 = ( sign = 0 ? 0x7FFFFFFF : 0x80000000 )
          DSPControlouflag:22 = 1
      endif
   endif
   return temp31..0
endfunction sat32ShiftLeft

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

To do a logical left shift of a word in a register without saturation, use the MIPS64 SLL instruction.

Encoding:

SPECIAL3

011111

rs

rt

rd

SHRAV.PH

01011

SHLL.QB

010011

SPECIAL3

011111

rs

rt

rd

SHRAV_R.PH

01111

SHLL.QB

010011

6

5

5

5

5

6

Format:

SHRAV[_R].PH 

Shift Right Arithmetic Variable Vector Pair Halfwords

SHRAV.PH   rd, rt, rs

MIPSDSP

Shift Right Arithmetic Variable Vector Pair Halfwords

SHRAV_R.PH rd, rt, rs

MIPSDSP

Shift Right Arithmetic Variable Vector Pair Halfwords

Purpose:

Shift Right Arithmetic Variable Vector Pair Halfwords

Element-wise arithmetic right shift of two independent halfwords in a vector data type by a variable number of bits, with optional rounding.

Description:

rd = sign_extend(rnd16(rt31..16 >> rs3..0) || rnd16(rt15..0 >> rs3..0))

The two right-most halfword values in register rt are each independently shifted right, with each value's original sign bit duplicated into the most-significant bits emptied by the shift. In the non-rounding variant of this instruction, the two independent results are then written to the corresponding halfword elements of destination register rd.

In the rounding variant of this instruction, a 1 is added at the most-significant discarded bit position before the results are written to destination register rd.

The shift amount sa is given by the four least-significant bits of register rs; the remaining bits of rs are ignored.

For both instructions, the sign of the left-most halfword result is sign-extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

SHRAV.PH:
   tempB15..0 = shift16RightArithmetic( GPR[rt]31..16, GPR[rs]3..0 )
   tempA15..0 = shift16RightArithmetic( GPR[rt]15..0, GPR[rs]3..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
SHRAV_R.PH:
   tempB15..0 = rnd16ShiftRightArithmetic( GPR[rt]31..16, GPR[rs]3..0 )
   tempA15..0 = rnd16ShiftRightArithmetic( GPR[rt]15..0, GPR[rs]3..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

SHRAV.QB

00110

SHLL.QB

010011

SPECIAL3

011111

rs

rt

rd

SHRAV_R.QB

00111

SHLL.QB

010011

6

5

5

5

5

6

Format:

SHRAV[_R].QB 

Shift Right Arithmetic Variable Vector of Four Bytes

SHRAV.QB     rd, rt, rs

MIPSDSP-R2

Shift Right Arithmetic Variable Vector of Four Bytes

SHRAV_R.QB   rd, rt, rs

MIPSDSP-R2

Shift Right Arithmetic Variable Vector of Four Bytes

Purpose:

Shift Right Arithmetic Variable Vector of Four Bytes

To execute an arithmetic right shift on four independent bytes by a variable number of bits.

Description:

rd = sign_extend(round(rt31..24 >> rs2..0)) || round(rt23..16 >> rs2..0) || round(rt15..8 >> rs2..0) || round(rt7..0 >> rs2..0)

The four right-most byte elements in register rt are each shifted right arithmetically by sa bits, then written to the corresponding byte elements in destination register rd. The sa argument is provided by the three least-significant bits of register rs, interpreted as an unsigned three-bit integer taking values from zero to seven. The remaining bits of rs are ignored.

In the rounding variant of the instruction, a value of 1 is added at the most significant discarded bit position of each result prior to writing the rounded result to the destination register.

The sign of the left-most byte result is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

SHRAV.QB:
   sa2..0 = GPR[rs]2..0
   if ( sa2..0 = 0 ) then
      tempD7..0 = GPR[rt]31..24
      tempC7..0 = GPR[rt]23..16
      tempB7..0 = GPR[rt]15..8
      tempA7..0 = GPR[rt]7..0
   else
      tempD7..0 = ( GPR[rt]31)sa || GPR[rt]31..24+sa )
      tempC7..0 = ( GPR[rt]23)sa || GPR[rt]23..16+sa )
      tempB7..0 = ( GPR[rt]15)sa || GPR[rt]15..8+sa )
      tempA7..0 = ( GPR[rt]7)sa || GPR[rt]7..sa )
   endif
   GPR[rd]63..0 = (tempD7)32 || tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0
SHRAV_R.QB:
   sa2..0 = GPR[rs]2..0
   if ( sa2..0 = 0 ) then
      tempD8..0 = ( GPR[rt]31..24 || 0)
      tempC8..0 = ( GPR[rt]23..16 || 0)
      tempB8..0 = ( GPR[rt]15..8 || 0)
      tempA8..0 = ( GPR[rt]7..0 || 0)
   else
      tempD8..0 = ( GPR[rt]31)sa || GPR[rt]31..24+sa-1 ) + 1
      tempC8..0 = ( GPR[rt]23)sa || GPR[rt]23..16+sa-1 ) + 1
      tempB8..0 = ( GPR[rt]15)sa || GPR[rt]15..8+sa-1 ) + 1
      tempA8..0 = ( GPR[rt]7)sa || GPR[rt]7..sa-1 ) + 1
   endif
   GPR[rd]63..0 = (tempD8)32 || tempD8..1 || tempC8..1 || tempB8..1 || tempA8..1

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

SHRAV_R.W

10111

SHLL.QB

010011

6

5

5

5

5

6

Format:

SHRAV_R.W rd, rt, rs

MIPSDSP

Shift Right Arithmetic Variable Word with Rounding

Purpose:

Shift Right Arithmetic Variable Word with Rounding

Arithmetic right shift with rounding of a signed 32-bit word by a variable number of bits.

Description:

rd = sign_extend(rnd32(rt31..0 >> rs4..0))

The right-most word value in register rt is shifted right, with the value's original sign bit duplicated into the most-significant bits emptied by the shift. A 1 is then added at the most-significant discarded bit position before the result is sign-extended and written to destination register rd.

The shift amount sa is given by the five least-significant bits of register rs; the remaining bits of rs are ignored.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

temp31..0 = rnd32ShiftRightArithmetic( GPR[rt]31..0, GPR[rs]4..0 )
GPR[rd]63..0 = (temp31)32 || temp31..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

sa

rt

rd

SHRA.PH

01001

SHLL.QB

010011

SPECIAL3

011111

0

sa

rt

rd

SHRA_R.PH

01101

SHLL.QB

010011

6

1

4

5

5

5

6

Format:

SHRA[_R].PH 

Shift Right Arithmetic Vector Pair Halfwords

SHRA.PH   rd, rt, sa

MIPSDSP

Shift Right Arithmetic Vector Pair Halfwords

SHRA_R.PH rd, rt, sa

MIPSDSP

Shift Right Arithmetic Vector Pair Halfwords

Purpose:

Shift Right Arithmetic Vector Pair Halfwords

Element-wise arithmetic right-shift of two independent halfwords in a vector data type by a fixed number of bits, with optional rounding.

Description:

rd = sign_extend(rnd16(rt31..16 >> sa) || rnd16(rt15..0 >> sa))

The two right-most halfword values in register rt are each independently shifted right by sa bits, with each value's original sign bit duplicated into the sa most-significant bits emptied by the shift.

In the non-rounding variant of this instruction, the two independent results are then written to the corresponding halfword elements of destination register rd.

In the rounding variant of the instruction, a 1 is added at the most-significant discarded bit position before the results are written to destination register rd.

For both instructions, the sign of the left-most halfword result is sign-extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

SHRA.PH:
   tempB15..0 = shift16RightArithmetic( GPR[rt]31..16, sa )
   tempA15..0 = shift16RightArithmetic( GPR[rt]15..0, sa )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
SHRA_R.PH:
   tempB15..0 = rnd16ShiftRightArithmetic( GPR[rt]31..16, sa )
   tempA15..0 = rnd16ShiftRightArithmetic( GPR[rt]15..0, sa )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
function shift16RightArithmetic( a15..0, s3..0 )
   if ( s3..0 = 0 ) then
      temp15..0 = a15..0
   else
      sign = a15
      temp15..0 = ( signs || a15..s )
   endif
   return temp15..0
endfunction shift16RightArithmetic
function rnd16ShiftRightArithmetic( a15..0, s3..0 )
   if ( s3..0 = 0 ) then
      temp16..0 = ( a15..0 || 0 )
   else
      sign = a15
      temp16..0 = ( signs || a15..s-1 )
   endif
   temp16..0 = temp + 1
   return temp16..1 
endfunction rnd16ShiftRightArithmetic

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

sa

rt

rd

SHRA.QB

00100

SHLL.QB

010011

SPECIAL3

011111

0

sa

rt

rd

SHRA_R.QB

00101

SHLL.QB

010011

6

2

3

5

5

5

6

Format:

SHRA[_R].QB 

Shift Right Arithmetic Vector of Four Bytes

SHRA.QB    rd, rt, sa

MIPSDSP-R2

Shift Right Arithmetic Vector of Four Bytes

SHRA_R.QB  rd, rt, sa

MIPSDSP-R2

Shift Right Arithmetic Vector of Four Bytes

Purpose:

Shift Right Arithmetic Vector of Four Bytes

To execute an arithmetic right shift on four independent bytes by a fixed number of bits.

Description:

rd = sign_extend(round(rt31..24 >> sa) || round(rt23..16 >> sa) || round(rt15..8 >> sa) || round(rt7..0 >> sa))

The four right-most byte elements in register rt are each shifted right arithmetically by sa bits, then written to the corresponding vector elements in destination register rd. The sa argument is interpreted as an unsigned three-bit integer taking values from zero to seven.

In the rounding variant of the instruction, a value of 1 is added at the most significant discarded bit position of each result prior to writing the rounded result to the destination register.

The sign of the left-most byte result is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

SHRA.QB:
   tempD7..0 = ( GPR[rt]31)sa || GPR[rt]31..24+sa )
   tempC7..0 = ( GPR[rt]23)sa || GPR[rt]23..16+sa )
   tempB7..0 = ( GPR[rt]15)sa || GPR[rt]15..8+sa )
   tempA7..0 = ( GPR[rt]7)sa || GPR[rt]7..sa )
   GPR[rd]63..0 = (tempD7)32 || tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0
SHRA_R.QB:
   if ( sa2..0 = 0 ) then
      tempD7..0 = GPR[rt]31..24
      tempC7..0 = GPR[rt]23..16
      tempB7..0 = GPR[rt]15..8
      tempA7..0 = GPR[rt]7..0
   else
      tempD8..0 = ( GPR[rt]31)sa || GPR[rt]31..24+sa-1 ) + 1
      tempC8..0 = ( GPR[rt]23)sa || GPR[rt]23..16+sa-1 ) + 1
      tempB8..0 = ( GPR[rt]15)sa || GPR[rt]15..8+sa-1 ) + 1
      tempA8..0 = ( GPR[rt]7)sa || GPR[rt]7..sa-1 ) + 1
   endif
   GPR[rd]63..0 = (tempD8)32 || tempD8..1 || tempC8..1 || tempB8..1 || tempA8..1

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

sa

rt

rd

SHRA_R.W

10101

SHLL.QB

010011

6

5

5

5

5

6

Format:

SHRA_R.W rd, rt, sa

MIPSDSP

Shift Right Arithmetic Word with Rounding

Purpose:

Shift Right Arithmetic Word with Rounding

To execute an arithmetic right shift with rounding on a word by a fixed number of bits.

Description:

rd = sign_extend(rnd32(rt31:0 >> sa))

The right-most word in register rt is shifted right by sa bits, and the sign bit is duplicated into the sa bits emptied by the shift. The shifted result is then rounded by adding a 1 bit to the most-significant discarded bit. The rounded result is then sign-extended to 64 bits and written to the destination register rd.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

temp31..0 = rnd32ShiftRightArithmetic( GPR[rt]31..0, sa4..0 )
GPR[rd]63..0 = (temp32)32 || temp32..1 
function rnd32ShiftRightArithmetic( a31..0, s4..0 )
   if ( s4..0 = 0 ) then
      temp32..0 = ( a31..0 || 0 )
   else
      sign = a31
      temp32..0 = ( signs || a31..s-1 )
   endif
   temp32..0 = temp + 1
   return temp32..1 
endfunction rnd32ShiftRightArithmetic

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

To do an arithmetic right shift of a word in a register without rounding, use the MIPS64 SRA instruction.

Encoding:

SPECIAL3

011111

0

sa

rt

rd

SHRL.PH

11001

SHLL.QB

010011

6

1

4

5

5

5

6

Format:

SHRL.PH rd, rt, sa

MIPSDSP-R2

Shift Right Logical Two Halfwords

Purpose:

Shift Right Logical Two Halfwords

To execute a right shift of two independent halfwords in a vector data type by a fixed number of bits.

Description:

rd = sign_extend((rt31..16 >> sa) || (rt15..0 >> sa))

The two right-most halfwords in register rt are independently logically shifted right, inserting zeros into the bit positions emptied by the shift. The two halfword results are then written to the corresponding halfword elements in destination register rd.

The shift amount is provided by the sa field, which is interpreted as a four bit unsigned integer taking values between

0 and 15.

The sign of the left-most halfword result is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempB15..0 = 0sa || GPR[rt]31..sa+16 
tempA15..0 = 0sa || GPR[rt]15..sa 
GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0 

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

0

00

sa

rt

rd

SHRL.QB

00001

SHLL.QB

010011

6

2

3

5

5

5

6

Format:

SHRL.QB rd, rt, sa

MIPSDSP

Shift Right Logical Vector Quad Bytes

Purpose:

Shift Right Logical Vector Quad Bytes

Element-wise logical right shift of four independent bytes in a vector data type by a fixed number of bits.

Description:

rd = sign_extend(rt31..24 >> sa) || (rt23..16 >> sa) || (rt15..8 >> sa) || (rt7..0 >> sa))

The four right-most byte values in register rt are each independently shifted right by sa bits and the sa most-significant bits of each value are set to zero. The four independent results are then written to the corresponding byte elements of destination register rd.

The sign of the left-most result is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempD7..0 = shift8Right( GPR[rt]31..24, sa )
tempC7..0 = shift8Right( GPR[rt]23..16, sa )
tempB7..0 = shift8Right( GPR[rt]15..8, sa )
tempA7..0 = shift8Right( GPR[rt]7..0, sa )
GPR[rd]63..0 = (tempD7)32 || tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0
function shift8Right( a7..0, s2..0 )
   if ( s2..0 = 0 ) then
      temp7..0 = a7..0
   else
      temp7..0 = ( 0s || a7..s )
   endif
   return temp7..0
endfunction shift8Right

Exceptions:

Reserved Instruction, DSP Disabled

Programming Notes:

To do a logical left shift of a word in a register without saturation, use the MIPS64 SLL instruction.

Encoding:

SPECIAL3

011111

rs

rt

rd

SHRLV.PH

11011

SHLL.QB

010011

6

5

5

5

5

6

Format:

SHRLV.PH rd, rt, rs

MIPSDSP-R2

Shift Variable Right Logical Pair of Halfwords

Purpose:

Shift Variable Right Logical Pair of Halfwords

To execute a right shift of two independent halfwords in a vector data type by a variable number of bits.

Description:

rd = sign_extend((rt31..16 >> rs3..0) || (rt15..0 >> rs3..0))

The two right-most halfwords in register rt are independently logically shifted right, inserting zeros into the bit positions emptied by the shift. The two halfword results are then written to the corresponding halfword elements in destination register rd.

The shift amount is provided by the four least-significant bits of register rs, which is interpreted as a four bit unsigned integer taking values between 0 and 15. The remaining bits of rs are ignored.

The sign of the left-most halfword result is extended into the 32 most-significant bits of the destination register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

sa3..0 = GPR[rs]3..0
tempB15..0 = 0sa || GPR[rt]31..sa+16 
tempA15..0 = 0sa || GPR[rt]15..sa 
GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0 

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

SHRLV.QB

00011

SHLL.QB

010011

6

5

5

5

5

6

Format:

SHRLV.QB rd, rt, rs

MIPSDSP

Shift Right Logical Variable Vector Quad Bytes

Purpose:

Shift Right Logical Variable Vector Quad Bytes

Element-wise logical right shift of four independent bytes in a vector data type by a variable number of bits.

Description:

rd = sign_extend((rt31..24 >> rs2..0) || (rt23..16 >> rs2..0) || (rt15..8 >> rs2..0) || (rt7..0 >> rs2..0))

The four right-most byte values in register rt are each independently shifted right, inserting zeros into the most-significant bit positions emptied by the shift. The four independent results are then written to the corresponding byte elements of destination register rd.

The sign of the left-most result is extended into the 32 most-significant bits of the destination register.

The three least-significant bits of rs provide the shift value, interpreted as an unsigned integer; the remaining bits of

rs are ignored.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

tempD7..0 = shift8Right( GPR[rt]31..24, GPR[rs]2..0 )
tempC7..0 = shift8Right( GPR[rt]23..16, GPR[rs]2..0 )
tempB7..0 = shift8Right( GPR[rt]15..8, GPR[rs]2..0 )
tempA7..0 = shift8Right( GPR[rt]7..0, GPR[rs]2..0 )
GPR[rd]63..0 = (tempD7)32 || tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

SUBQH.PH

01001

ADDUH.QB

011000

SPECIAL3

011111

rs

rt

rd

SUBQH_R.PH

01011

ADDUH.QB

011000

6

5

5

5

5

6

Format:

SUBQH[_R].PH 

Subtract Fractional Halfword Vectors And Shift Right to Halve Results

SUBQH.PH     rd, rs, rt

MIPSDSP-R2

Subtract Fractional Halfword Vectors And Shift Right to Halve Results

SUBQH_R.PH   rd, rs, rt

MIPSDSP-R2

Subtract Fractional Halfword Vectors And Shift Right to Halve Results

Purpose:

Subtract Fractional Halfword Vectors And Shift Right to Halve Results

Element-wise fractional subtraction of halfword vectors, with a right shift by one bit to halve each result, with optional rounding.

Description:

rd = sign_extend(round((rs31..16 - rt31..16) >> 1) || round((rs15..0 - rt15..0) >> 1))

Each element from the two right-most halfword values in register rt is subtracted from the corresponding halfword element in register rs to create an interim 17-bit result.

In the non-rounding instruction variant, each interim result is then shifted right by one bit before being written to the corresponding halfword element of destination register rd.

In the rounding version of the instruction, a value of 1 is added at the least-significant bit position of each interim result; the interim result is then right-shifted by one bit and written to the destination register.

This instruction does not modify the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

SUBQH.PH:
   tempB15..0 = rightShift1SubQ16( GPR[rs]31..16 , GPR[rt]31..16 )
   tempA15..0 = rightShift1SubQ16( GPR[rs]15..0 , GPR[rt]15..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
SUBQH_R.PH:
   tempB15..0 = roundRightShift1SubQ16( GPR[rs]31..16 , GPR[rt]31..16 )
   tempA15..0 = roundRightShift1SubQ16( GPR[rs]15..0 , GPR[rt]15..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
function rightShift1SubQ16( a15..0 , b15..0 )
   temp16..0 = (( a15 || a15..0 ) - ( b15 || b15..0 ))
   return temp16..1
endfunction rightShift1SubQ16
function roundRightShift1SubQ16( a15..0 , b15..0 )
   temp16..0 = (( a15 || a15..0 ) - ( b15 || b15..0 ))
   temp16..0 = temp16..0 + 1
   return temp16..1
endfunction roundRightShift1SubQ16

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

SUBQH.W

10001

ADDUH.QB

011000

SPECIAL3

011111

rs

rt

rd

SUBQH_R.W

10011

ADDUH.QB

011000

6

5

5

5

5

6

Format:

SUBQH[_R].W 

Subtract Fractional Words And Shift Right to Halve Results

SUBQH.W     rd, rs, rt

MIPSDSP-R2

Subtract Fractional Words And Shift Right to Halve Results

SUBQH_R.W   rd, rs, rt

MIPSDSP-R2

Subtract Fractional Words And Shift Right to Halve Results

Purpose:

Subtract Fractional Words And Shift Right to Halve Results

Fractional subtraction of word vectors, with a right shift by one bit to halve the result, with optional rounding.

Description:

rd = sign_extend(round((rs31..0 - rt31..0) >> 1))

The right-most word in register rt is subtracted from the word in register rs to create an interim 33-bit result.

In the non-rounding instruction variant, the interim result is then shifted right by one bit before being written to the destination register rd.

In the rounding version of the instruction, a value of 1 is added at the least-significant bit position of the interim result; the interim result is then right-shifted by one bit and written to the destination register.

This instruction does not modify the DSPControl register.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

SUBQH.W:
   tempA31..0 = rightShift1SubQ32( GPR[rs]31..0 , GPR[rt]31..0 )
   GPR[rd]63..0 = (tempB15)32 || tempA31..0
SUBQH_R.W:
   tempA31..0 = roundRightShift1SubQ32( GPR[rs]31..0 , GPR[rt]31..0 )
   GPR[rd]63..0 = (tempB15)32 || tempA31..0
function rightShift1SubQ32( a31..0 , b31..0 )
   temp32..0 = (( a31 || a31..0 ) - ( b31 || b31..0 ))
   return temp32..1
endfunction rightShift1SubQ32
function roundRightShifttSubQ32( a31..0 , b31..0 )
   temp32..0 = (( a31 || a31..0 ) - ( b31 || b31..0 ))
   temp32..0 = temp32..0 + 1
   return temp32..1
endfunction roundRightShift1SubQ32

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

SUBQ.PH

01011

ADDU.QB

010000

SPECIAL3

011111

rs

rt

rd

SUBQ_S.PH

01111

ADDU.QB

010000

6

5

5

5

5

6

Format:

SUBQ[_S].PH 

Subtract Fractional Halfword Vector

SUBQ.PH   rd, rs, rt

MIPSDSP

Subtract Fractional Halfword Vector

SUBQ_S.PH rd, rs, rt

MIPSDSP

Subtract Fractional Halfword Vector

Purpose:

Subtract Fractional Halfword Vector

Element-wise subtraction of one vector of Q15 fractional halfword values from another to produce a vector of Q15 fractional halfword results, with optional saturation.

Description:

rd = sign_extend(sat16(rs31..16 - rt31..16)) || sat16(rs15..0 - rt15..0)

The two right-most fractional halfwords in register rt are subtracted from the corresponding fractional halfword elements in register rs.

For the non-saturating version of this instruction, each result is written to the corresponding element in register rd. In the case of overflow or underflow, the result modulo 2 is written to register rd.

For the saturating version of the instruction, the subtraction is performed using signed saturating arithmetic. If the operation results in an overflow or an underflow, the result is clamped to either the largest representable value

(0x7FFF hexadecimal) or the smallest representable value (0x8000 hexadecimal), respectively, before being written to the destination register rd.

For both instructions, the left-most result is sign-extended into the 32 most-significant bits of the destination register.

For both instructions, if any of the individual subtractions result in underflow, overflow, or saturation, a 1 is written to bit 20 in the DSPControl register within the ouflag field.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

SUBQ.PH:
   tempB15..0 = subtract16( GPR[rs]31..16 , GPR[rt]31..16 )
   tempA15..0 = subtract16( GPR[rs]15..0 , GPR[rt]15..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
SUBQ_S.PH:
   tempB15..0 = sat16Subtract( GPR[rs]31..16 , GPR[rt]31..16 )
   tempA15..0 = sat16Subtract( GPR[rs]15..0 , GPR[rt]15..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
function subtract16( a15..0, b15..0 ) 
   temp16..0 = ( a15 || a15..0 ) - ( b15 || b15..0 )
   if ( temp16 != temp15 ) then
      DSPControlouflag:20 = 1
   endif
   return temp15..0
endfunction subtract16
function sat16Subtract( a15..0, b15..0 )
   temp16..0 = ( a15 || a15..0 ) - ( b15|| b15..0 )
   if ( temp16 != temp15 ) then
      if ( temp16 = 0 ) then
          temp = 0x7FFF
      else
          temp = 0x8000
      endif
      DSPControlouflag:20 = 1
   endif
   return temp15..0
endfunction sat16Subtract

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

SUBQ_S.W

10111

ADDU.QB

010000

6

5

5

5

5

6

Format:

SUBQ_S.W rd, rs, rt

MIPSDSP

Subtract Fractional Word

Purpose:

Subtract Fractional Word

One Q31 fractional word is subtracted from another to produce a Q31 fractional result, with saturation.

Description:

rd = sign_extend(sat32(rs31..0 - rt31..0))

The right-mostQ31 fractional word in register rt is subtracted from the corresponding fractional word in register rs, and the 32-bit result is sign-extended to 64 bits and written to destination register rd. The subtraction is performed using signed saturating arithmetic. If the operation results in an overflow or an underflow, the result is clamped to either the largest representable value (0x7FFFFFFF hexadecimal) or the smallest representable value (0x80000000 hexadecimal), respectively, before being sign-extended and written to the destination register rd.

If the subtraction results in underflow, overflow, or saturation, a 1 is written to bit 20 in the DSPControl register within the ouflag field.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

temp31..0 = sat32Subtract( GPR[rs]31..0 , GPR[rt]31..0 )
GPR[rd]63..0 = (temp31)32 || temp31..0
function sat32Subtract( a31..0, b31..0 ) 
   temp32..0 = ( a31 || a31..0 ) - ( b31 || b31..0 )
   if ( temp32 != temp31) then
      if ( temp32 = 0 ) then
          temp31..0 = 0x7FFFFFFF
      else
          temp31..0 = 0x80000000
      endif
      DSPControlouflag:20 = 1
   endif
   return temp31..0
endfunction sat32Subtract

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

SUBUH

00001

ADDUH.QB

011000

SPECIAL3

011111

rs

rt

rd

SUBUH_R

00011

ADDUH.QB

011000

6

5

5

5

5

6

Format:

SUBUH[_R].QB 

Subtract Unsigned Bytes And Right Shift to Halve Results

SUBUH.QB    rd, rs, rt

MIPSDSP-R2

Subtract Unsigned Bytes And Right Shift to Halve Results

SUBUH_R.QB  rd, rs, rt

MIPSDSP-R2

Subtract Unsigned Bytes And Right Shift to Halve Results

Purpose:

Subtract Unsigned Bytes And Right Shift to Halve Results

Element-wise subtraction of two vectors of unsigned bytes, with a one-bit right shift to halve results and optional rounding.

Description:

rd = sign_extend(round((rs31..24 - rt31..24)>>1) || round((rs23..16 - rt23..16)>>1) || round((rs15..8 - rt15..8)>>1) || round((rs7..0 - rt7..0)>>1))

The four right-mostunsigned byte values in register rt are subtracted from the corresponding unsigned byte values in register rs. Each unsigned result is then halved by shifting right by one bit position. The byte results are then written to the corresponding elements of destination register rd.

In the rounding variant of the instruction, a value of 1 is added to the result of each subtraction at the discarded bit position before the right shift.

The sign of the left-most byte result is extended into the 32 most-significant bits of the destination register.

The results of this instruction never overflow; no bits of the ouflag field in the DSPControl register are written.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

SUBUH.QB:
   tempD7..0 = ( ( 0 || GPR[rs]31..24 ) - ( 0 || GPR[rt]31..24 )) >> 1
   tempC7..0 = ( ( 0 || GPR[rs]23..16 ) - ( 0 || GPR[rt]23..16 )) >> 1
   tempB7..0 = ( ( 0 || GPR[rs]15..8 ) - ( 0 || GPR[rt]15..8 )) >> 1
   tempA7..0 = ( ( 0 || GPR[rs]7..0 ) - ( 0 || GPR[rt]7..0 )) >> 1
   GPR[rd]63..0 = (tempD7)32 || tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0
SUBUH_R.QB:
   tempD7..0 = ( ( 0 || GPR[rs]31..24 ) - ( 0 || GPR[rt]31..24 ) + 1) >> 1
   tempC7..0 = ( ( 0 || GPR[rs]23..16 ) - ( 0 || GPR[rt]23..16 ) + 1) >> 1
   tempB7..0 = ( ( 0 || GPR[rs]15..8 ) - ( 0 || GPR[rt]15..8 ) + 1) >> 1
   tempA7..0 = ( ( 0 || GPR[rs]7..0 ) - ( 0 || GPR[rt]7..0 ) + 1) >> 1
   GPR[rd]63..0 = (tempD7)32 || tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

SUBU.PH

01001

ADDU.QB

010000

SPECIAL3

011111

rs

rt

rd

SUBU_S.PH

01101

ADDU.QB

010000

6

5

5

5

5

6

Format:

SUBU[_S].PH 

Subtract Unsigned Integer Halfwords

SUBU.PH    rd, rs, rt

MIPSDSP-R2

Subtract Unsigned Integer Halfwords

SUBU_S.PH  rd, rs, rt

MIPSDSP-R2

Subtract Unsigned Integer Halfwords

Purpose:

Subtract Unsigned Integer Halfwords

Element-wise subtraction of pairs of unsigned integer halfwords, with optional saturation.

Description:

rd = sign_extend(sat16(rs31..16 - rt31..16) || sat16(rs15..0 - rt15..0))

The two right-most unsigned integer halfwords in register rs are subtracted from the corresponding unsigned integer halfwords in register rt. The unsigned results are then written to the corresponding element in destination register rd.

In the saturating version of the instruction, if either subtraction results in an underflow the result is clamped to the minimum unsigned integer halfword value (0x0000 hexadecimal), before being written to the destination register rd.

Bit 31 of the result is extended into the 32 most-significant bits of the destination register.

For both instruction variants, if either subtraction causes an underflow the instruction writes a 1 to bit 20 in the

DSPControl register in the ouflag field.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

SUBU.PH:
   tempB15..0 = subtractU16U16( GPR[rt]31..16 , GPR[rs]31..16 )
   tempA15..0 = subtractU16U16( GPR[rt]15..0 , GPR[rs]15..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
SUBU_S.PH:
   tempB15..0 = satU16SubtractU16U16( GPR[rt]31..16 , GPR[rs]31..16 )
   tempA15..0 = satU16SubtractU16U16( GPR[rt]15..0 , GPR[rs]15..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
function subtractU16U16( a15..0, b15..0 ) 
   temp16..0 = ( 0 || a15..0 ) - ( 0 || b15..0 )
   if ( temp16 = 1 ) then
      DSPControlouflag:20 = 1 
   endif
   return temp15..0
endfunction subtractU16U16 
function satU16SubtractU16U16( a15..0, b15..0 ) 
   temp16..0 = ( 0 || a15..0 ) - ( 0 || b15..0 )
   if ( temp16 = 1 ) then
      temp15..0 = 0x0000
      DSPControlouflag:20 = 1 
   endif
   return temp15..0
endfunction satU16SubtractU16U16

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

rt

rd

SUBU.QB

00001

ADDU.QB

010000

SPECIAL3

011111

rs

rt

rd

SUBU_S.QB

00101

ADDU.QB

010000

6

5

5

5

5

6

Format:

SUBU[_S].QB 

Subtract Unsigned Quad Byte Vector

SUBU.QB   rd, rs, rt

MIPSDSP

Subtract Unsigned Quad Byte Vector

SUBU_S.QB rd, rs, rt

MIPSDSP

Subtract Unsigned Quad Byte Vector

Purpose:

Subtract Unsigned Quad Byte Vector

Element-wise subtraction of one vector of unsigned byte values from another to produce a vector of unsigned byte results, with optional saturation.

Description:

rd = sign_extend(sat8(rs31..24 - rt31..24)) || sat8(rs23..16 - rt23..16) || sat8(rs15..8 - rt15..8) || sat8(rs7..0 - rt7..0)

The four right-most byte elements in rt are subtracted from the corresponding byte elements in register rs.

For the non-saturating version of the instruction, the result modulo 256 is written into the corresponding position in register rd.

For the saturating version of the instruction the subtraction is performed using unsigned saturating arithmetic. If the subtraction results in underflow, the value is clamped to the smallest representable value (0 decimal, 0x00 hexadecimal) before being written to the destination register rd.

For each instruction, the sign of the left-most byte result is extended into the 32 most-significant bits of the destination register.

For each instruction, if any of the individual subtractions result in underflow or saturation, a 1 is written to bit 20 in the DSPControl register within the ouflag field.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

SUBU.QB:
   tempD7..0 = subtractU8( GPR[rs]31..24 , GPR[rt]31..24 )
   tempC7..0 = subtractU8( GPR[rs]23..16 , GPR[rt]23..16 )
   tempB7..0 = subtractU8( GPR[rs]15..8 , GPR[rt]15..8 )
   tempA7..0 = subtractU8( GPR[rs]7..0 , GPR[rt]7..0 )
   GPR[rd]63..0 = (tempD7)32 || tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0
SUBU_S.QB:
   tempD7..0 = satU8Subtract( GPR[rs]31..24 , GPR[rt]31..24 )
   tempC7..0 = satU8Subtract( GPR[rs]23..16 , GPR[rt]23..16 )
   tempB7..0 = satU8Subtract( GPR[rs]15..8 , GPR[rt]15..8 )
   tempA7..0 = satU8Subtract( GPR[rs]7..0 , GPR[rt]7..0 )
   GPR[rd]63..0 = (tempD7)32 || tempD7..0 || tempC7..0 || tempB7..0 || tempA7..0
function subtractU8( a7..0, b7..0 ) 
   temp8..0 = ( 0 || a7..0 ) - ( 0 || b7..0 )
   if ( temp8 = 1 ) then
      DSPControlouflag:20 = 1
   endif
   return temp7..0
endfunction subtractU8
function satU8Subtract( a7..0, b7..0 )
   temp8..0 = ( 0 || a7..0 ) - ( 0 || b7..0 )
   if ( temp8 = 1 ) then
      temp7..0 = 0x00
      DSPControlouflag:20 = 1
   endif
   return temp7..0
endfunction satU8Subtract

Exceptions:

Reserved Instruction, DSP Disabled

Encoding:

SPECIAL3

011111

rs

mask

WRDSP

10011

EXTR.W

111000

6

5

10

5

6

Format:

WRDSP rs, mask

MIPSDSP

Write Fields to DSPControl Register from a GPR

Purpose:

Write Fields to DSPControl Register from a GPR

To copy selected fields from the specified GPR to the special-purpose DSPControl register.

Description:

DSPControl = select(mask, GPR[rs])

Selected fields in the special register DSPControl are overwritten with the corresponding bits from the source GPR rs.

Each of bits 0 through 5 of the mask operand corresponds to a specific field in the DSPControl register. A mask bit value of 1 indicates that the field will be overwritten using the bits from the same bit positions in register rs, and a mask bit value of 0 indicates that the corresponding field will be unchanged. Bits 6 through 9 of the mask operand are ignored.

The table below shows the correspondence between the bits in the mask operand and the fields in the DSPControl register; mask bit 0 is the least-significant bit in mask.

ccond

ouflag

0

EFI

C

scount

pos

4

3

5

2

1

0

For example, to overwrite only the scount field in DSPControl, the value of the mask operand used will be 2 decimal

(0x02 hexadecimal). After execution of the instruction, the scount field in DSPControl will have the value of bits 7 through 12 of the specified source register rs and the remaining bits in DSPControl are unmodified.

The one-operand version of the instruction provides a convenient assembly idiom that allows the programmer to write all the allowable fields in the DSPControl register from the source GPR, i.e., it is equivalent to specifying a

mask value of 31 decimal (0x1F hexadecimal).

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

newbits31..0 = 032
overwrite31..0 = 0xFFFFFFFF
if ( mask0 = 1 ) then
   overwrite6..0 = 07
   newbits6..0 = GPR[rs]6..0
endif
if ( mask1 = 1 ) then
   overwrite12..7 = 06
   newbits12..7 = GPR[rs]12..7
endif
if ( mask2 = 1 ) then
   overwrite13 = 0
   newbits13 = GPR[rs]13
endif
if ( mask3 = 1 ) then
   overwrite23..16 = 08
   newbits23..16 = GPR[rs]23..16
endif
if ( mask4 = 1 ) then
   overwrite31..24 = 08
   newbits31..24 = GPR[rs]31..24
endif
if ( mask5 = 1 ) then
   overwrite14 = 0
   newbits14 = GPR[rs]14
endif
DSPControl = DSPControl and overwrite31..0
DSPControl = DSPControl or new31..0

Exceptions:

Reserved Instruction, DSP Disabled