No. As many variables as needed may be pushed onto the stack (in step 4.)
This results in the rule that a subroutine (in a language like C or Java) can have as many local variables as needed.
main
is started by QTSPIM and returns control to QTSPIM.
Because of this, it needs different rules.
main's Prolog ( done at the start of main):
main's Body:
- QTSPIM has set up the stack pointer register
$sp.- Initialize the frame pointer:
$fp = $sp - space_for_variables. The space for variables is four times the number of local variables.
- Adjust the stack pointer:
$sp = $fp.
- main may use any register
- main refers to local variables as
disp($fp).- main may push and pop values on the stack using
$sp.
Calling a Subroutine (as done by main):
- Push any registers
$t0-$t9that contain values that must be saved.- Put argument values into
$a0-$a3.- Call the subroutine using
jal.
Regaining Control from a Subroutine (as done by main):
- Pop any registers
$t0-$t9that main pushed in step 7.
main's Epilog (done at the end of main):
- Load
$s0with 10.- Return to QTSPIM using
syscall.
Could main just not bother to use T
registers?