Encoding:

POOL32A

000000

rt

rs

rd

0

MODSUB

1010010101

6

5

5

5

1

10

SPECIAL3

011111

rs

rt

rd

MODSUB

10010

ADDU.QB

010000

6

5

5

5

5

6

Format:

MODSUB  rd, rs, rt

microMIPSDSP

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