Question: Consider C Code Example 6.27. For this exercise, assume factorial is called with input argument n = 5. (a) What value is in $v0 when

Consider C Code Example 6.27. For this exercise, assume factorial is called with input argument n = 5.
(a) What value is in $v0 when factorial returns to the calling function?
(b) Suppose you delete the instructions at addresses 0x98 and 0xBC that save and restore $ra. Will the program
(1) enter an infinite loop but not crash;
(2) crash (cause the stack to grow beyond the dynamic data segment or the PC to jump to a location outside the program);
(3) produce an incorrect value in $v0 when the program returns to loop (if so, what value?), or
(4) run correctly despite the deleted lines?
(c) Repeat part (b) when the instructions at the following instruction addresses are deleted:
(i) 0x94 and 0xC0 (instructions that save and restore $a0)
(ii) 0x90 and 0xC4 (instructions that save and restore $sp). Note: the factorial label is not deleted
(iii) 0xAC (an instruction that restores $sp)

Step by Step Solution

3.42 Rating (161 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a 120 b 2 c i 3 returne... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Digital Design Computer Questions!