This is an optimization for speed. Many subroutines neeed to use only a few registers. They can use the "T" registers without the added expense of saving and restoring them.
Those rules are somewhat complicated. Here is a picture. It shows the four sections of subroutine linkage. The basic tasks of each section are:
Subroutine Call: Push all "T" registers that contain
values that will be needed after the call.
Put arguments in "A" registers.
jal
to the subroutine.
Prolog: If this subroutine calls other subroutines,
push $ra
. Push all "S" registers that the subroutine alters.
Body: Normal code, except that it must follow these conventions. "T" and "A" registers can be used freely, as can any "S" registers that were saved in the prolog.
Epilog: Put return values in "V" registers. Pop any "S" registers. Pop$ra
if it was pushed in the prolog.back to the caller. jr $ra
Return: Pop any "T" registers that were previously pushed.