Consider C Code Example 6.27. For this exercise, assume factorial is called with input argument n =

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 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)

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question
Question Posted: