[prev] 3 [next]

Static vs Automatic Allocation (cont)

Automatic allocation:
  • variables local to a function
Prefer to put local vars in registers, but if cannot ...
  • use space allocated on stack during function prologue
  • referenced during function relative to $fp
  • space reclaimed from stack in function epilogue
Example:

int fx(int a[])
{
   int i, j, max;
   i = 1; j = 2; max = i+j;
   ...
}