MIPS R2000 instruction set



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.



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







Put the negative of the integer from register Rsrc into register Rdest.




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



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






Constant-Manipulating Instructions



Move the immediate imm into register Rdest.




Comparison Instructions

In all instructions below, Src2 can either be a register or an immediate value (a 16 bit integer).



Set register Rdest to 1 if register Rsrc1 equals Src2 and to be 0 otherwise.

Set register Rdest to 1 if register Rsrc1 is greater than or equal to Src2 and to 0 otherwise.






Branch and Jump Instructions

In all instructions below, Src2 can either be a register or an immediate value (integer). Branch instructions use a signed 16-bit offset field; hence they can jump 215 - 1 instructions (not bytes) forward or 215instructions backwards. The jump instruction contains a 26 bit address field.




Conditionally branch to the instruction at the label if coprocessor z's condition flag is true (false).

Conditionally branch to the instruction at the label if the contents of register Rsrc1 equals Src2.

Conditionally branch to the instruction at the label if the contents of Rsrc equals 0.

Conditionally branch to the instruction at the label if the contents of register Rsrc1 are greater than or equal to Src2.














Unconditionally jump to the instruction whose address is in register Rsrc.



Load Instructions



  • la Rdest, address           Load Address
  • Load computed address, not the contents of the location, into register Rdest.

  • lb Rdest, address           Load Byte
  • lbu Rdest, address          Load Unsigned Byte
  • Load the byte at address into register Rdest. The byte is sign-extended by the lb, but not the lbu, instruction.

  • ld Rdest, address           Load Double-Word
  • Load the 64-bit quantity at address into registers Rdest and Rdest + 1.

  • lh Rdest, address           Load Halfword
  • lhu Rdest, address          Load Unsigned Halfword
  • Load the 16-bit quantity (halfword) at address into register Rdest. The halfword is sign-extended by the lh, but not the lhu, instruction


    Load the 32-bit quantity (word) at address into register Rdest.

  • lwcz Rdest, address         Load Word Coprocessor
  • Load the word at address into register Rdest of coprocessor z (0-3).

  • lwl Rdest, address          Load Word Left
  • lwr Rdest, address          Load Word Right
  • Load the left (right) bytes from the word at the possibly-unaligned address into register Rdest.

  • ulh Rdest, address          Unaligned Load Halfword
  • ulhu Rdest, address         Unaligned Load Halfword Unsigned
  • Load the 16-bit quantity (halfword) at the possibly-unaligned address into register Rdest. The halfword is sign-extended by the ulh, but not the ulhu, instruction

  • ulw Rdest, address          Unaligned Load Word
  • Load the 32-bit quantity (word) at the possibly-unaligned address into register Rdest.



    Store Instructions



  • sb Rsrc, address         Store Byte
  • Store the low byte from register Rsrc at address.

  • sd Rsrc, address         Store Double-Word
  • Store the 64-bit quantity in registers Rsrc and Rsrc + 1 at address.

  • sh Rsrc, address         Store Halfword
  • Store the low halfword from register Rsrc at address.

  • sw Rsrc, address         Store Word
  • Store the word from register Rsrc at address.

  • swcz Rsrc, address       Store Word Coprocessor
  • Store the word from register Rsrc of coprocessor z at address.

  • swl Rsrc, address        Store Word Left
  • swr Rsrc, address        Store Word Right
  • Store the left (right) bytes from register Rsrc at the possibly-unaligned address.

  • ush Rsrc, address        Unaligned Store Halfword
  • Store the low halfword from register Rsrc at the possibly-unaligned address.

  • usw Rsrc, address        Unaligned Store Word
  • Store the word from register Rsrc at the possibly-unaligned address.



    Data Movement Instructions



  • move Rdest, Rsrc             Move
  • Move the contents of Rsrc to Rdest.


    The multiply and divide unit produces its result in two additional registers, hi and lo. These instructions move values to and from these registers. The multiply, divide, and remainder instructions described above are pseudoinstructions that make it appear as if this unit operates on the general registers and detect error conditions such as divide by zero or overflow.

  • mfhi Rdest                  Move From hi
  • mflo Rdest                  Move From lo
  • Move the contents of the hi (lo) register to register Rdest.
  • mthi Rdest                  Move To hi
  • mtlo Rdest                  Move To lo
  • Move the contents register Rdest to the hi (lo) register.


    Coprocessors have their own register sets. These instructions move values between these registers and the CPU's registers.

  • mfcz Rdest, CPsrc          Move From Coprocessor z
  • Move the contents of coprocessor z's register CPsrc to CPU register Rdest.
  • mfc1.d Rdest, FRsrc1       Move Double From Coprocessor 1
  • Move the contents of floating point registers FRsrc1 and FRsrc1 + 1 to CPU registers Rdest and Rdest + 1.
  • mtcz Rsrc, CPdest          Move To Coprocessor z
  • Move the contents of CPU register Rsrc to coprocessor z's register CPdest.



    Floating Point Instructions



    The MIPS has a floating point coprocessor (numbered 1) that operates on single precision (32-bit) and double precision (64-bit) floating point numbers. This coprocessor has its own registers, which are numbered $f0-$f31. Because these registers are only 32-bits wide, two of them are required to hold doubles. To simplify matters, floating point operations only use even-numbered registers-including instructions that operate on single floats.

    Values are moved in or out of these registers a word (32-bits) at a time by lwc1, swc1, mtc1, and mfc1 instructions described above or by the l.s, l.d, s.s, and s.d pseudoinstructions described below. The flag set by floating point comparison operations is read by the CPU with its bc1t and bc1f instructions.

    In all instructions below, FRdest, FRsrc1, FRsrc2, and FRsrc are floating point registers (e.g., $f2).


  • abs.d FRdest, FRsrc           Floating Point Absolute Value Double
  • abs.s FRdest, FRsrc           Floating Point Absolute Value Single
  • Compute the absolute value of the floating float double (single) in register FRsrc and put it in register FRdest.

  • add.d FRdest, FRsrc1, FRsrc2  Floating Point Addition Double
  • add.s FRdest, FRsrc1, FRsrc2  Floating Point Addition Single
  • Compute the sum of the floating float doubles (singles) in registers FRsrc1 and FRsrc2 and put it in register FRdest.

  • c.eq.d FRsrc1, FRsrc2         Compare Equal Double
  • c.eq.s FRsrc1, FRsrc2         Compare Equal Single
  • Compare the floating point double in register FRsrc1 against the one in FRsrc2 and set the floating point condition flag true if they are equal.

  • c.le.d FRsrc1, FRsrc2         Compare Less Than Equal Double
  • c.le.s FRsrc1, FRsrc2         Compare Less Than Equal Single
  • Compare the floating point double in register FRsrc1 against the one in FRsrc2 and set the floating point condition flag true if the first is less than or equal to the second.

    Compare the floating point double in register FRsrc1 against the one in FRsrc2 and set the condition flag true if the first is less than the second.

    Convert the single precision floating point number or integer in register FRsrc to a double precision number and put it in register FRdest.

    Convert the double precision floating point number or integer in register FRsrc to a single precision number and put it in register FRdest.

    Convert the double or single precision floating point number in register FRsrc to an integer and put it in register FRdest.

    Compute the quotient of the floating float doubles (singles) in registers FRsrc1 and FRsrc2 and put it in register FRdest.

    Load the floating float double (single) at address into register FRdest.

    Move the floating float double (single) from register FRsrc to register FRdest.

    Compute the product of the floating float doubles (singles) in registers FRsrc1 and FRsrc2 and put it in register FRdest.

    Negate the floating point double (single) in register FRsrc and put it in register FRdest.

    Store the floating float double (single) in register FRdest at address.

    Compute the difference of the floating float doubles (singles) in registers FRsrc1 and FRsrc2 and put it in register FRdest.



    Exception and Trap Instructions



    Restore the Status register.

    Register $v0 contains the number of the system call (see Table 1) provided by SPIM.

    Cause exception n. Exception 1 is reserved for the debugger.

    Do nothing.