MIPS Instructions

The instructions implemented in the model are:

Load/Store Instructions:

InstructionDescriptionExampleResult
LBLoad ByteLB R3 1(R0) Loads Byte from memory location 1
LBULoad Byte UnsignedLBU R4 1(R0) Loads Byte Unsigned from memory location 1
SBStore ByteSB R1 1(R0) Stores Byte in R1 into memory location 1
LHLoad HalfwordLH R4 2(R0)

Loads Halfword from memory location 2 into R4

LHULoad Halfword UnsignedLHU R4 2(R0) Loads Halfword Unsigned from memory location 2 into R4
LUILoad Upper ImmediateLUI R1 124 Load 124 in the upper half of regester R1
SHStore HalfwordSH R5 6(R0) Stores Halfword from R5 into memory loction 6
LWLoad WordLW R4 8(R0) Loads Word from data memory loaction word 8 into R4
SWStore WordSW R3 16(R0) Stores Word in R3 into location 16 in data memory
LWC1Load Word to an FPRLWC1 F0 0(R0) Loads Word from data memory location word 0 into F0
SWC1Store Word from FPRSWC1 F1 8(RO) Stores Word in F1 into location 8 in data memory

Arithmetic Integer Instructions:

InstructionDescriptionExampleResult
ADDIAdd Immediate WordADDI R1 R2 -4 Store R2 + -4 in R1
ADDIUAdd Immediate Unsigned WordADDIU R1 R2 16 Store R2 + 16 in R1
ADDAdd WordADD R1 R2 R3 Store R2 + R3 in R1
ADDUAdd Word UnsignedADD R1 R2 R3 Store R2 + R3 in R1
MULTMultiply integersMULT R1 R2 Store R1 x R2 in HI register
MULTUMultiply unsigned integersMULTU R3 R4 Store R3 x R4 in HI register
DIVDivide integersDIV R1 R2 Store R1 / R2 in HI register
DIVUDivide unsigned integerDIVU R3 R4 Store R3 / R4 in HI register
SUBSubtract WordSUB R1 R2 R3 Store R2 - R3 in R1
SUBUSubtract Word UnsignedSUB R1 R2 R3 Store R2 - R3 in R1
SLTSet on less thanSLT R1 R2 R3 If R2 is less than R3 set R1 to be 1 else set it to 0
SLTISet on less than ImmediateSLTI R1 R2 5 If R2 is less than 5 then set R1 to 1 else set it to 0
SLTUSet on less than UnsignedSLTU R1 R2 R3 If the unsigned value of R2 is less than the unsigned value R3 set R1 to 1 else set it to 0
SLTIUSet on less than Immediate UnsignedSLTIU R1 R2 6 If the R2 is less than 6 (after sign extension)set R1 to 1 else set it to 0

Logical Instructions:

InstructionDescriptionExampleResult
ANDAndAND R1 R2 R3 Stores result of R2 AND R3 into R1
ANDIAnd ImmediateANDI R1 R1 19 Stores the result of R1 AND 19 back into R1
OROrOR R1 R2 R3 Stores result of R2 OR R3 into R1
ORIOr ImmediateORI R1 R1 128 Stores the result of R1 OR 128 back into R1
XORExclusive OrXOR R1 R2 R3 Stores result of R2 XOR R3 into R1
XORIExclusive Or ImmediateXORI R1 R1 64 Stores the result of R1 OR 64 back into R1
NORNorNOR R1 R2 R3 Stores result of R2 NOR R3 into R1
SSLShift Word Left LogicalSSL R1 R2 4 Shift R2 4 bits to the left and store in R1
SRLShift Word Right LogicalSRL R1 R2 2 Shift R2 2 bits to the right and store in R1
SRAShift Word Right ArithmeticSRA R3 R4 2 Arithmetically shift R4 2 bits right and store in R3
SLLVShift Word Left Logical VariableSLLV R1 R2 R3 Shift R2 left by R3 bits and store in R1
SRLVShift Word Right Logical VariableSRLV R1 R2 R3 Shift R2 right by R3 bits and store in R1
SRAVShift Word Right Arithmetic VariableSRAV R1 R2 R3 Shift R2 right arithmetically by R3 bits and store in R1

Jump Instructions:

InstructionDescriptionExample Result
BC1FBranch on FP condition code falseBC1F loop Branch to label 'loop' if FP code is false
BC1TBranch on FP condition code trueBCT1 loop Branch to label 'loop' if FP code is true
JJumpJ 8 Jump to instruction 8
JRJump RegisterJ R1 Jump to the instruction number held in R1

Branch Instructions:

InstructionDescriptionExample Result
BEQBranch on equalBEQ R1 R2 4 Branch forward 4 instructions if R1 and R2 are equal
BNEBranch on not equalBNE R1 R2 8 Branch forward 8 instructions if R1 and R2 are not equal
BLEZBranch on less than or equal to zeroBLEZ R2 -2 Branch back 2 instructions if R2 is less than or equal to zero
BGTZBranch on greater than zeroBGTZ R2 -2 Branch back 2 instructions if R2 is greater than zero
BLTZBranch on less than zeroBLTZ R2 3 Branch forward 3 instructions if R2 is less than zero
BGEZBranch on greater than or equal to zeroBGTZ R2 5 Branch forward 5 instructions if R2 is greater than or equal to zero

Other Instructions:

InstructionDescriptionExample Result
BREAKBreakpointBREAK Halt
NOPNo OperationNOP No operation

Move Instructions:

InstructionDescriptionExample Result
MFHICopy the special purpose HI register to a GPR MFHI R2Copies the HI register to R2
MFLOCopy the special purpose LO register to a GPRMFLO R2 Copies the LO register to R2
MTHICopy a GPR to the special purpose HI registerMFHI R5 Copies R5 to the HI register
MTLOCopy a GPR to the special purpose LO registerMFLO R5 Copies R5 to the LO register
MTC1Copy a word from a GPR to a FPU register MTC1 R3 F2 Copies R3 to F2
MFC1Copy a word from a FPU register to a GPR MFC1 R5 F3 Copies F3 to R5
MOVSCopy a word between FPU registers MOVS F1 F2 Copies F2 to F1

Floating point Conversion Instructions:

InstructionDescriptionExample Result
CVTWSConvert a FP value to a 32-bit fixed-point value CVTWS F0 F2 The value in F2 is converted to a 32-bit word and stored in F0
CVTSWConvert a 32-bit fixed-point to a FP value CVTSW F0 F1 The value in F1 is converted to a FP value and stored in F0

Floating point Arithmetic Instructions:

InstructionDescriptionExample Result
ABSSCompute absolute value of an FP value ABSS F2 F3 Store absolute value of F3 in F2
ADDSAdd FP valuesADDS F1 F2 F3 Store F2 + F3 in F1
NEGSNegate an FP valueNEGS F1 F2 The negated value of F2 is stored in F1
SUBSSubtract FP valuesSUB F1 F2 F3 Store F2 - F3 in F1
MULSMultiply FP valuesMULS F1 F2 F3 Store F2 x F3 in F1
DIVSDivide FP valuesDIVS F1 F2 F3 Store F2 / F3 in F1

Floating point Compare Instructions:

InstructionDescriptionExample Result
CFSSet FP condition code falseCFS R1 R2 Sets FP condition code false
CEQSSet FP condition code on equalCEQS R2 R3 Sets FP condition code true if R2 is equal to R3 else set it false
COLTSSet FP condition code on less thanCOLTS R3 R4 Sets FP condition code true if R3 is less than R4 else set it false
COLESSet FP condition code on less than or equal to COLES R4 R5 Sets FP condition code true if R4 is less than or equal to R5 else set it false