go to previous page   go to home page   go to next page

Answer:

No.

Example Program

The number of registers that MIPS (or other processor) has does not limit the number of variables that subroutines can have. As many variables as you want can be allocated on the stack. Here is an example program, written in a C-like language.

main()
{
  int a;
  a = mysub( 6 );
  print( a );
}

int mysub( int arg )
{
  int b,c;
  
  b = arg*2;
  c = b + 7;
  
  return c;  
}

To the operating system, main() is a subroutine. When main() first gets control it must follow the rules under "subroutine prolog".

QUESTION 8:

How much space on the stack is needed for the variables in main()?