go to previous page   go to home page   go to next page hear noise highlighting

Answer:

Sure. As long as there are enough S registers available.


Example Program

Here is an example program, written in a C-like language.

When main first gets control the stack pointer $sp has been initialized to point to the top of stack. main() then follows the rules under "Rules for Main".

The prolog for main sets up its local variables using the frame pointer $fp

For qtSPIM, return to the system is done using trap handler service 10 and the syscall instruction.


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

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


QUESTION 9:

How many bytes on the stack are needed for the variables in main?


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