See below.
fact()
The
alternate branch of the if
statement
(at symbolic address recurse
)
has the job of calculating n*fact(n-1)
.
It does this by first calculating the argument
n-1
.
Then it calls the subroutine fact()
in the normal way.
It does not hurt for fact()
to call fact()
because
each activation has its own data on the stack.
On return from the (inner) call to fact()
,
register $v0
has the returned value, and
register $s1
has the argument n
.
Now the return value from the current activation must be
placed in $v0
to be returned to the caller.
Fill in the blanks. (Hint: study the last paragraph).