Next: Constant-Manipulating Instructions Up: Description of the MIPS Previous: Addressing Modes

## Arithmetic and Logical Instructions

In all instructions below, Src2 can either be a register or an immediate value (a 16 bit integer). The immediate forms of the instructions are only included for reference. The assembler will translate the more general form of an instruction (e.g., add) into the immediate form (e.g., addi) if the second argument is constant.

 abs Rdest, Rsrc Absolute Value
Put the absolute value of the integer from register Rsrc in register Rdest.

Put the sum of the integers from register Rsrc1 and Src2 (or Imm) into register Rdest.

 and Rdest, Rsrc1, Src2 AND
 andi Rdest, Rsrc1, Imm AND Immediate
Put the logical AND of the integers from register Rsrc1 and Src2 (or Imm) into register Rdest.

 div Rsrc1, Rsrc2 Divide (with overflow)
 divu Rsrc1, Rsrc2 Divide (without overflow)
Divide the contents of the two registers. Leave the quotient in register lo and the remainder in register hi. Note that if an operand is negative, the remainder is unspecified by the MIPS architecture and depends on the conventions of the machine on which SPIM is run.

 div Rdest, Rsrc1, Src2 Divide (with overflow)
 divu Rdest, Rsrc1, Src2 Divide (without overflow)
Put the quotient of the integers from register Rsrc1 and Src2 into register Rdest.

 mul Rdest, Rsrc1, Src2 Multiply (without overflow)
 mulo Rdest, Rsrc1, Src2 Multiply (with overflow)
 mulou Rdest, Rsrc1, Src2 Unsigned Multiply (with overflow)
Put the product of the integers from register Rsrc1 and Src2 into register Rdest.

 mult Rsrc1, Rsrc2 Multiply
 multu Rsrc1, Rsrc2 Unsigned Multiply
Multiply the contents of the two registers. Leave the low-order word of the product in register lo and the high-word in register hi.

 neg Rdest, Rsrc Negate Value (with overflow)
 negu Rdest, Rsrc Negate Value (without overflow)
Put the negative of the integer from register Rsrc into register Rdest.

 nor Rdest, Rsrc1, Src2 NOR
Put the logical NOR of the integers from register Rsrc1 and Src2 into register Rdest.

 not Rdest, Rsrc NOT
Put the bitwise logical negation of the integer from register Rsrc into register Rdest.

 or Rdest, Rsrc1, Src2 OR
 ori Rdest, Rsrc1, Imm OR Immediate
Put the logical OR of the integers from register Rsrc1 and Src2 (or Imm) into register Rdest.

 rem Rdest, Rsrc1, Src2 Remainder
 remu Rdest, Rsrc1, Src2 Unsigned Remainder
Put the remainder from dividing the integer in register Rsrc1 by the integer in Src2 into register Rdest. Note that if an operand is negative, the remainder is unspecified by the MIPS architecture and depends on the conventions of the machine on which SPIM is run.

 rol Rdest, Rsrc1, Src2 Rotate Left
 ror Rdest, Rsrc1, Src2 Rotate Right
Rotate the contents of register Rsrc1 left (right) by the distance indicated by Src2 and put the result in register Rdest.

 sll Rdest, Rsrc1, Src2 Shift Left Logical
 sllv Rdest, Rsrc1, Rsrc2 Shift Left Logical Variable
 sra Rdest, Rsrc1, Src2 Shift Right Arithmetic
 srav Rdest, Rsrc1, Rsrc2 Shift Right Arithmetic Variable
 srl Rdest, Rsrc1, Src2 Shift Right Logical
 srlv Rdest, Rsrc1, Rsrc2 Shift Right Logical Variable
Shift the contents of register Rsrc1 left (right) by the distance indicated by Src2 (Rsrc2) and put the result in register Rdest.

 sub Rdest, Rsrc1, Src2 Subtract (with overflow)
 subu Rdest, Rsrc1, Src2 Subtract (without overflow)
Put the difference of the integers from register Rsrc1 and Src2 into register Rdest.

 xor Rdest, Rsrc1, Src2 XOR
 xori Rdest, Rsrc1, Imm XOR Immediate
Put the logical XOR of the integers from register Rsrc1 and Src2 (or Imm) into register Rdest.

Next: Constant-Manipulating Instructions Up: Description of the MIPS Previous: Addressing Modes

Antony Hosking
Fri Apr 12 10:48:03 EST 1996