Procedures: Two Analogies


Procedures: A Seven-Step Program


Calling Program:

Procedure:


Program ---> $a0
$a1
$a2
$a3
   
$ra ---> Procedure
    .       use $a0 - $a3
    .
    .       set $v0, $v1
  return to program
   
$v0
$v1
<---
Program <---

New Instructions

New Registers


Note About Saved/Unsaved Registers

The conventions/rules of MIPS are that subfunctions may change the values of some registers, but not all of them.


Alyce Brady, Kalamazoo College