Mips Instruction Format Cheat Sheet Page 9

ADVERTISEMENT

The structure of the procedure
Leaf:
subi $sp, $sp, 12
# $sp = $sp-12, make room
sw $t1, 8($sp)
# save $t1 on stack
sw $t0, 4($sp)
# save $t0 on stack
sw $s0, 0($sp)
# save $s0 on stack
Now we can use the registers $t1, $t0, $s0 in the body
of the procedure.
add $t0, $a1, $a2
# $t0 = g + h
add $ t1, $a2, $a3
# $t1 = i + j
sub $s0, $t0, $t1
# $s0 = (g + h) – (i + j)
Return the result into the register $v0.
add $v0, $s0, $zero
# returns f = (g+h)-(i+j) to $v0

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education