MIPS Instruction Reference
MIPS Instruction Reference
MIPS Instruction Reference
Note: ALL arithmetic immediate values are sign-extended. After that, they are handled as signed or unsigned 32 bit numbers, depending upon the instruction. The only difference between signed and unsigned instructions is that signed instructions can generate an overflow exception and unsigned instructions can not. The instruction descriptions are given below:
07/10/2013
Syntax: Encoding:
www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html
07/10/2013
Encoding:
0 0 0 00 0 s ss s s tt t t td d d dd 0 0 00 0 1 00 1 0 0
www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html
07/10/2013
07/10/2013
Description: Branches if the two registers are not equal Operation: if $s != $t advance_pc (offset << 2)); else advance_pc (4); Syntax: Encoding: bne $s, $t, offset
0 0 0 10 1 s ss s s tt t t ti i i ii i i ii i i ii i i i
DIV -- Divide
Description: Divides $s by $t and stores the quotient in $LO and the remainder in $HI Operation: $LO = $s / $t; $HI = $s % $t; advance_pc (4); Syntax: Encoding: div $s, $t
0 0 0 00 0 s ss s s tt t t t0 0 0 00 0 0 00 0 0 11 0 1 0
J -- Jump
Description: Jumps to the calculated address Operation: PC = nPC; nPC = (PC & 0xf0000000) | (target << 2); Syntax: Encoding: j target
0 0 0 01 0 i ii i i ii i i ii i i ii i i ii i i ii i i i
07/10/2013
Operation: $31 = PC + 8 (or nPC + 4); PC = nPC; nPC = (PC & 0xf0000000) | (target << 2); Syntax: Encoding: jal target
0 0 0 01 1 i ii i i ii i i ii i i ii i i ii i i ii i i i
JR -- Jump register
Description: Jump to the address contained in register $s Operation: PC = nPC; nPC = $s; Syntax: Encoding: jr $s
0 0 0 00 0 s ss s s 00 0 0 00 0 0 00 0 0 00 0 0 01 0 0 0
LB -- Load byte
Description: A byte is loaded into a register from the specified address. Operation: $t = MEM[$s + offset]; advance_pc (4); Syntax: Encoding: lb $t, offset($s)
1 0 0 00 0 s ss s s tt t t ti i i ii i i ii i i ii i i i
LW -- Load word
Description: A word is loaded into a register from the specified address. Operation: $t = MEM[$s + offset]; advance_pc (4);
www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html 6/12
07/10/2013
Syntax: Encoding:
lw $t, offset($s)
1 0 0 01 1 s ss s s tt t t ti i i ii i i ii i i ii i i i
MULT -- Multiply
Description: Multiplies $s by $t and stores the result in $LO. Operation: $LO = $s * $t; advance_pc (4); Syntax: Encoding: mult $s, $t
0 0 0 00 0 s ss s s tt t t t0 0 0 00 0 0 00 0 0 11 0 0 0
www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html
07/10/2013
Encoding:
0 0 0 00 0 s ss s s tt t t t0 0 0 00 0 0 00 0 0 11 0 0 1
NOOP -- no operation
Description: Performs no operation. Operation: advance_pc (4); Syntax: Encoding: noop
0 0 0 00 0 0 00 0 0 00 0 0 00 0 0 00 0 0 00 0 0 00 0 0 0
Note: The encoding for a NOOP represents the instruction SLL $0, $0, 0 which has no side effects. In fact, nearly every instruction that has $0 as its destination register will have no side effect and can thus be considered a NOOP instruction.
OR -- Bitwise or
Description: Bitwise logical ors two registers and stores the result in a register Operation: $d = $s | $t; advance_pc (4); Syntax: Encoding: or $d, $s, $t
0 0 0 00 0 s ss s s tt t t td d d dd 0 0 00 0 1 00 1 0 1
SB -- Store byte
Description: The least significant byte of $t is stored at the specified address. Operation: MEM[$s + offset] = (0xff & $t); advance_pc (4);
www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html 8/12
07/10/2013
Syntax: Encoding:
sb $t, offset($s)
1 0 1 00 0 s ss s s tt t t ti i i ii i i ii i i ii i i i
07/10/2013
Encoding:
0 0 1 01 0 s ss s s tt t t ti i i ii i i ii i i ii i i i
www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html
07/10/2013
SUB -- Subtract
Description: Subtracts two registers and stores the result in a register Operation: $d = $s - $t; advance_pc (4); Syntax: Encoding: sub $d, $s, $t
0 0 0 00 0 s ss s s tt t t td d d dd 0 0 00 0 1 00 0 1 0
SW -- Store word
Description: The contents of $t is stored at the specified address. Operation: MEM[$s + offset] = $t; advance_pc (4); Syntax: Encoding: sw $t, offset($s)
1 0 1 01 1 s ss s s tt t t ti i i ii i i ii i i ii i i i
www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html
11/12
07/10/2013
The syscall instruction is described in more detail on the System Calls page.
www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html
12/12