MIPS Instruction Set Architecture


Register Arithmetic Operations:


add rd, rs, rt :


Puts the sum of the integers in the register rs and the register rt into register rd and checks for overflow.

31-26
25-21
20-16
15-11
10-6
5-0
000000
rs
rt
rd
00000
100000


addu rd, rs, rt :

Puts the sum of the integers in the register rs and the register rt into register rd and does not check for overflow.

31-26
25-21
20-16
15-11
10-6
5-0
000000
rs
rt
rd
00000
100001


sub rd, rs, rt :

Subtracts the integer in register rt from the integer in register rs, putting the result into register rd and checks for overflow.

31-26
25-21
20-16
15-11
10-6
5-0
000000
rs
rt
rd
00000
100010


subu rd, rs, rt :

Subtracts the integer in register rt from the integer in register rs, putting the result into register rd and does not check for overflow.

31-26
25-21
20-16
15-11
10-6
5-0
000000
rs
rt
rd
00000
100011


mult rs, rt :

Multiplies the signed integers in registers rs and rt. Leave the low-order word of the product in register lo and the high-order word in register hi.

31-26
25-21
20-16
15-11
10-6
5-0
000000
rs
rt
00000
00000
011000


multu rs, rt :

Multiplies the unsigned integers in registers rs and rt. Leave the low-order word of the product in register lo and the high-order word in register hi.

31-26
25-21
20-16
15-11
10-6
5-0
000000
rs
rt
00000
00000
011001


Register Logic Operations:

and rd, rs, rt :

Puts the logical AND of the integers from register rs and rt into register rd.

31-26
25-21
20-16
15-11
10-6
5-0
000000
rs
rt
rd
00000
100100


or rd, rs, rt :

Puts the logical OR of the integers from register rs and rt into register rd.

31-26
25-21
20-16
15-11
10-6
5-0
000000
rs
rt
rd
00000
100101


xor rd, rs, rt :

Puts the logical XOR of the integers from register rs and rt into register rd.

31-26
25-21
20-16
15-11
10-6
5-0
000000
rs
rt
rd
00000
100110


nor rd, rs, rt :

Puts the logical NOR of the integers from register rs and rt into register rd.

31-26
25-21
20-16
15-11
10-6
5-0
000000
rs
rt
rd
00000
100111


Register Shift Operations:

sll rd, rt, shamt :

Performs logical shift of contents of register rt left by shamt bits, putting results into register rd.  Vacated bits are filled with 0's.

31-26
25-21
20-16
15-11
10-6
5-0
000000
00000
rt
rd
shamt
000000


srl rd, rt, shamt :

Performs logical shift of contents of register rt right by shamt bits, putting results into register rd.  Vacated bits are filled with 0's.

31-26
25-21
20-16
15-11
10-6
5-0
000000
00000
rt
rd
shamt
000010


sra rd, rt, shamt :

Performs aritmetic shift of contents of register rt right by shamt bits, putting results into register rd.  Vacated bits are filled with replicas of sign bit.

31-26
25-21
20-16
15-11
10-6
5-0
000000
00000
rt
rd
shamt
000011


Miscellaneous Immediate Instructions:

lui rt, imm :

Load the immediate value imm into the upper half-word of register rt. The lower bits of the resgister are set to 0.

31-26
25-21
20-16
15-0
001111
00000
rt
imm


Register Comparison Operations:

slt rd, rs, rt :

If the signed integer in register rs is less than the signed integer in register rt then store the value 0x00000001 in register rd, otherwise store the value 0x00000000 there.

31-26
25-21
20-16
15-11
10-6
5-0
000000
rs
rt
rd
00000
101010


sltu rd, rs, rt :

If the unsigned integer in register rs is less than the unsigned integer in register rt then store the value 0x00000001 in register rd, otherwise store the value 0x00000000 there.

31-26
25-21
20-16
15-11
10-6
5-0
000000
rs
rt
rd
00000
101011


Immediate Arithmetic Operations:

addi rt, rs, imm :

Put the sum of the integer in register rs and the sign extended immediate value imm into the register rt and check for overflow.

31-26
25-21
20-16
15-0
001000
rs
rt
imm


addiu rt, rs, imm :

Put the sum of the integer in register rs and the sign extended immediate value imm into the register rt and do not check for overflow.

31-26
25-21
20-16
15-0
001001
rs
rt
imm


Immediate Logic Operations:

andi rt, rs, imm :

Put the logical AND of the value in the register rs and the zero extended immediate value imm into register rt.

31-26
25-21
20-16
15-0
001100
rs
rt
imm


ori rt, rs, imm :

Put the logical OR of the value in the register rs and the zero extended immediate value imm into register rt.

31-26
25-21
20-16
15-0
001101
rs
rt
imm


xori rt, rs, imm :

Put the logical XOR of the value in the register rs and the zero extended immediate value imm into register rt.

31-26
25-21
20-16
15-0
001110
rs
rt
imm


Immediate Comparison Operations:

slti rt, rs, imm :

If the signed integer in register rs is less than the sign extended immediate imm then store the value 0x00000001 in register rt, otherwise store the value 0x00000000 there.

31-26
25-21
20-16
15-0
001010
rs
rt
imm


Load and Store Operations:


lw rt, Offset(rs) :

Get word at address = Offset(rs) = rs + Offset and load it into register rt. The word must be aligned, meaning the address must be evenly divisible by four.

31-26
25-21
20-16
15-0
100011
rs
rt
Offset


sw rt, Offset(rs) :

Store the word from register rt at address = Offset(rs) = rs + Offset.

31-26
25-21
20-16
15-0
101011
rs
rt
Offset


Branch Operations:

beq rs, rt, label : (label is transated to a 16 bit Offset by the assembler)

If the integer in register rs is equal to the integer in register rt, then increment the program counter (PC) by Offset * 4.

31-26
25-21
20-16
15-0
000100
rs
rt
Offset


bne rs, rt, label : (label is transated to a 16 bit Offset by the assembler)

If the integer in register rs is not equal to the integer in register rt, then increment the program counter (PC) by Offset * 4.

31-26
25-21
20-16
15-0
000101
rs
rt
Offset


bgez rs, label : (label is transated to a 16 bit Offset by the assembler)

If the integer in register rs is greater than or equal to zero, then increment the PC by Offset * 4.

31-26
25-21
20-16
15-0
000001
rs
00001
Offset


Jump Operations:

j target :

Unconditionally jump to instruction at Target.

31-26
25-0
000010
Target


jal target :

Save address of the next instruction in register 31 and then unconditionally jump to instruction at Target.

31-26
25-0
000011
Target


jr rs :

Unconditionally jump to instruction at address stored in rs.

31-26
25-21
20-6
5-0
000000
rs
don't care
001000


Register Movement Operations:


mfhi rd :


Copies the contents of the hi register to register rd.

31-26
25-21
20-16
15-11
10-6
5-0
000000
00000
00000
rd
00000
010000


mflo rd :


Copies the contents of the lo register to register rd.

31-26
25-21
20-16
15-11
10-6
5-0
000000
00000
00000
rd
00000
010010


Miscellaneous Operations:


nop :


No operation. Used to insert a stall into a pipeline.

31-26
25-21
20-16
15-11
10-6
5-0
000000
00000
00000
00000
00000
000000