Question: the given MIPS 3 2 benchmark program below computes factorial, Suppose you implemented PUSH $n and POP the former pushes ( Sn ) onto the
the given MIPS benchmark program below computes factorial, Suppose you implemented PUSH $n and POP the former pushes Sn onto the stack and the latter pops off TOS into $n while SP is adjusted automatically. Rewrite this program PUSH and POP. b How many memory cycles do you save when calculating m
fact: addi$ $ # initialize reg. to
beq$ $ return# if n then gotoreturn:
bne$ $ continue # if n then gotocontinue:
return: addi$ $ # assign result
jr$ # return
continue: addi$ $ # allocate stack space for fp ra n
sw$$ # save frame pointer
sw$$ # save return address
addi$ $ # update frame pointer
sw $$# save n
addi$ $ # make n
jalfact # recursive call to factn
lw $$ # restore n
mult $ $ # fact n n
mflo$ # put product in result reg.
lw$$ # restore return address
lw$$ # restore frame pointer
addi $ $ # restore stack pointer
jr$ # return
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
