next up previous
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 tex2html_wrap_inline1278
Put the absolute value of the integer from register Rsrc in register Rdest.

add Rdest, Rsrc1, Src2 Addition (with overflow)
addi Rdest, Rsrc1, Imm Addition Immediate (with overflow)
addu Rdest, Rsrc1, Src2 Addition (without overflow)
addiu Rdest, Rsrc1, Imm Addition Immediate (without overflow)
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) tex2html_wrap_inline1278
divu Rdest, Rsrc1, Src2 Divide (without overflow) tex2html_wrap_inline1278
Put the quotient of the integers from register Rsrc1 and Src2 into register Rdest.

mul Rdest, Rsrc1, Src2 Multiply (without overflow) tex2html_wrap_inline1278
mulo Rdest, Rsrc1, Src2 Multiply (with overflow) tex2html_wrap_inline1278
mulou Rdest, Rsrc1, Src2 Unsigned Multiply (with overflow) tex2html_wrap_inline1278
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) tex2html_wrap_inline1278
negu Rdest, Rsrc Negate Value (without overflow) tex2html_wrap_inline1278
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 tex2html_wrap_inline1278
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 tex2html_wrap_inline1278
remu Rdest, Rsrc1, Src2 Unsigned Remainder tex2html_wrap_inline1278
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 tex2html_wrap_inline1278
ror Rdest, Rsrc1, Src2 Rotate Right tex2html_wrap_inline1278
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 up previous
Next: Constant-Manipulating Instructions Up: Description of the MIPS Previous: Addressing Modes

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