Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started