Skip to content

Instantly share code, notes, and snippets.

@candh
Last active November 14, 2018 15:40
Show Gist options
  • Save candh/d393397f18dac4b3fb3bb514b9699b0e to your computer and use it in GitHub Desktop.
Save candh/d393397f18dac4b3fb3bb514b9699b0e to your computer and use it in GitHub Desktop.
i made this so i dont have to look at others

MIPS cheatsheet

bold ones are important

R type instructions

Name OP Code Funct Instruction C equivalent
add 0 32 add $rd, $rs, $rt a = b + c
sub 0 34 sub $rd, $rs, $rt a = b - c
and 0 36 and $rd, $rs, $rt a = b & c
or 0 37 or $rd, $rs, $rt a = b | c
xor 0 38 xor $rd, $rs, $rt a = b ^ c
nor 0 39 nor $rd, $rs, $rt a = !(b | c)
slt 0 42 slt $rd, $rs, $rt a = (b < c)

I type instructions

Z is a constant

Name OP Code Instruction C equivalent
sll 0 sll $rd, $rt, const a = b << Z
srl 2 srl $rd, $rt, const a = b >> Z
beq 4 beq $rs, $rt, imm if(a==b)
bne 5 bne $rs, $rt, imm if(a!=b)
addi 8 addi $rt, $rs, imm a = b + Z
slti 10 slti $rt, $rs, imm a = b < Z
andi 12 andi $rt, $rs, imm a = b & Z
ori 13 ori $rt, $rs, imm a = b | Z
xori 14 xori $rt, $rs, imm a = b ^ Z
lw 35 lw $rt, imm($rs) a = b[Z]
sw 43 sw $rt, imm($rs) b[Z] = a

J type instructions

Name OP Code Instruction C equivalent
j 2 j label goto label

More Here: https://inst.eecs.berkeley.edu/~cs61c/resources/MIPS_help.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment