Mi Ps Reference

You might also like

You are on page 1of 2

MIPS Reference Sheet

Arithmetic Instruction add $d, $s, $t addu $d, $s, $t addi $t, $s, i addiu $t, $s, i and $d, $s, $t andi $t, $s, i div $s, $t divu $s, $t mult $s, $t multu $s, $t nor $d, $s, $t or $d, $s, $t ori $t, $s, i sll $d, $t, a sllv $d, $t, $s sra $d, $t, a srav $d, $t, $s srl $d, $t, a srlv $d, $t, $s sub $d, $s, $t subu $d, $s, $t xor $d, $s, $t xori $d, $s, i and Logical Instructions Operation $d = $s + $t $d = $s + $t $t = $s + SE(i) $t = $s + SE(i) $d = $s & $t $t = $s & ZE(i) lo = $s / $t; hi = $s % $t lo = $s / $t; hi = $s % $t hi:lo = $s * $t hi:lo = $s * $t $d = ~($s | $t) $d = $s | $t $t = $s | ZE(i) $d = $t << a $d = $t << $s $d = $t >> a $d = $t >> $s $d = $t >>> a $d = $t >>> $s $d = $s - $t $d = $s - $t $d = $s ^ $t $d = $s ^ ZE(i) Branch Instructions Instruction Operation beq $s, $t, label if ($s == $t) pc += i << 2 bgtz $s, label if ($s > 0) pc += i << 2 blez $s, label if ($s <= 0) pc += i << 2 bne $s, $t, label if ($s != $t) pc += i << 2 Jump Instructions Instruction Operation j label pc += i << 2 jal label $31 = pc; pc += i << 2 jalr $s $31 = pc; pc = $s jr $s pc = $s Instruction lb $t, i($s) lbu $t, i($s) lh $t, i($s) lhu $t, i($s) lw $t, i($s) Instruction sb $t, i($s) sh $t, i($s) sw $t, i($s) Load Instructions Operation $t = SE (MEM [$s + i]:1) $t = ZE (MEM [$s + i]:1) $t = SE (MEM [$s + i]:2) $t = ZE (MEM [$s + i]:2) $t = MEM [$s + i]:4 Store Instructions Operation MEM [$s + i]:1 = LB ($t) MEM [$s + i]:2 = LH ($t) MEM [$s + i]:4 = $t

Constant-Manipulating Instructions Instruction Operation lhi $t, i HH($t) = i LH($t) = i llo $t, i Comparison Instructions Instruction Operation slt $d, $s, $t $d = ($s < $t) sltu $d, $s, $t $d = ($s < $t) slti $t, $s, i $t = ($s < SE(i)) sltiu $t, $s, i $t = ($s < SE(i))

Data Movement Instructions Instruction Operation mfhi $d $d = hi mo $d $d = lo mthi $s hi = $s mtlo $s lo = $s Exception and Interrupt Instructions Instruction Operation trap 1 Print integer value in $4 trap 5 Read integer value into $2 trap 10 Terminate program execution trap 101 Print ASCII character in $4 trap 102 Read ASCII character into $2

Note: Detailed encoding reference on reverse.

Register Immediate Jump

Instruction Encodings 000000ss sssttttt dddddaaa aaffffff ooooooss sssttttt iiiiiiii iiiiiiii ooooooii iiiiiiii iiiiiiii iiiiiiii

Syntax ArithLog DivMult Shift ShiftV JumpR MoveFrom MoveTo ArithLogI LoadI Branch BranchZ LoadStore Jump Trap

Template f $d, $s, $t f $s, $t f $d, $t, a f $d, $t, $s f $s f $d f $s o $t, $s, i o $t, immed32 o $s, $t, label o $s, label o $t, i($s) o label o i

Instruction Syntax Encoding Comments Register Register Register Register Register Register Register Immediate Immediate i is high or low 16 bits of immed32 Immediate i is calculated as (label-(current+4))>>2 Immediate i is calculated as (label-(current+4))>>2 Immediate Jump i is calculated as label<<2 Jump

Opcode Table Instruction add addu addi addiu and andi div divu mult multu nor or ori sll sllv sra srav srl srlv sub subu xor xori lhi llo Opcode/Function 100000 100001 001000 001001 100100 001100 011010 011011 011000 011001 100111 100101 001101 000000 000100 000011 000111 000010 000110 100010 100011 100110 001110 011001 011000 Syntax ArithLog ArithLog ArithLogI ArithLogI ArithLog ArithLogI DivMult DivMult DivMult DivMult ArithLog ArithLog ArithLogI Shift ShiftV Shift ShiftV Shift ShiftV ArithLog ArithLog ArithLog ArithLogI LoadI LoadI Instruction slt sltu slti sltiu beq bgtz blez bne j jal jalr jr lb lbu lh lhu lw sb sh sw mfhi mo mthi mtlo trap Opcode/Function 101010 101001 001010 001001 000100 000111 000110 000101 000010 000011 001001 001000 100000 100100 100001 100101 100011 101000 101001 101011 010000 010010 010001 010011 011010 Syntax ArithLog ArithLog ArithLogI ArithLogI Branch BranchZ BranchZ Branch Jump Jump JumpR JumpR LoadStore LoadStore LoadStore LoadStore LoadStore LoadStore LoadStore LoadStore MoveFrom MoveFrom MoveTo MoveTo Trap

Note: Operation details on reverse. 2

You might also like