MIPS: Summary After Procedures

 


Arithmetic Instructions

Name Syntax Meaning
add add $rd, $rs, $rt $rd = $rs + $rt
addu addu $rd, $rs, $rt $rd = $rs + $rt (unsigned)
sub sub $rd, $rs, $rt $rd = $rs - $rt
subu subu $rd, $rs, $rt $rd = $rs - $rt (unsigned)
addi addi $rd, $rs, constantValue $rd = $rs + constantValue
addiu addiu $rd, $rs, constantValue $rd = $rs + constantValue (unsigned)

Logical Instructions (so far)

Name Syntax Meaning
sll (shift left logical) sll $rd, $rs, shiftAmount shift $rd by shiftAmount, put in $rd
srl (shift right logical) srl $rd, $rs, shiftAmount shift $rd by shiftAmount, put in $rd

Memory Access Instructions (so far)

Name Syntax Meaning
lw (load word) lw $rd, offset($base) load word from address ($base+offset) to $rd
sw (store word) sw $rs, offset($base) store word from $rs to address ($base+offset)

Branch-Related Instructions (so far)

Name Syntax Meaning
beq (branch on equal) beq $rs, $rt, label branch to label if $rs == $rt
bne (branch on not equal) bne $rs, $rt, label branch to label if $rs != $rt
slt (set on less than) slt $rd, $rs, $rt set $rd to 1 if $rs < $rt
sltu (set on less than) sltu $rd, $rs, $rt set $rd to 1 if $rs < $rt (unsigned)

Jump Instructions

Name Syntax Meaning
jr jr $ra jump to the address in $ra
j j label jump to the address associated with label
jal jal label store the program counter (PC) in $ra and then
jump to the address associated with label

Registers (so far)

Number Name Comments
0$zero constant 0
...
2
3
 $v0 
 $v1 
results of a function (not preserved across function call)
results of a function
4
5
6
7
 $a0 
 $a1 
 $a2 
 $a3 
argument 1 (not preserved across function call)
argument 2
argument 3
argument 4
8
.
.
.
15
$t0
.
.
.
$t7
temporary (not preserved across function call)
.
.
.
temporary (not preserved across function call)
16
.
.
.
23
$s0
.
.
.
$s7
saved temporary (preserved across function call)
.
.
.
saved temporary (preserved across function call)
24
25
$t8
$t9
temporary (not preserved across function call)
temporary (not preserved across function call)
...
29
30
31
 $sp 
 $fp 
 $ra 
stack pointer
frame pointer
return address (set by jal, not preserved)

There is also special PC register, to which programmers do not have direct access.

 


Alyce Brady, Kalamazoo College