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

Answer:

No.

This violates the idea of modularity. Now if subX is revised it might alter T registers and break main.


Diagram

two linked subroutines

These rules are somewhat complicated. Here is a picture. The basic tasks of each section are:

Subroutine Call: Put arguments in A registers. jal to the subroutine.
Prolog: Push $ra. Push all S registers that the subroutine might alter.
Body: Normal code, except that it must follow these conventions if it calls a subroutine. T registers 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. jr $ra back to the caller.
Regaining Control: Use S registers as before the call. Don't assume T registers are the same.

QUESTION 7:

Is there any limit in these rules about how many levels deep subroutine calls may be?


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