Question: Suppose in a program there is a main procedure, and three other procedures: proc1 , proc2 and proc3 . Assume that main calls proc1 ,

Suppose in a program there is a main procedure, and three other procedures: proc1, proc2 and proc3. Assume that main calls proc1, then proc1 calls proc2, and finally proc2calls proc3. There are no other procedure calls. The picture below shows a snapshot of the stack just before proc2 calls proc3.

I know the answers to these questions but I would like to get a detailed explanation for them:

Suppose in a program there is a main procedure, and three other

A. Which of the following registers are being preserved by proc1 so they can be restored before returning to main?

ans: $ra, $fp, $s2, and $s3

B. Which of the following registers are being protected by proc1 from being altered by proc2?

ans: $t0 and $t1

C. How many arguments are needed by proc2 when it is called by proc1?

ans: 5

D. Which of the following registers are being preserved by proc2 so they can be restored before returning to proc1?

ans: $ra, $fp, $s0, $s1

E. Which of the following registers are being protected by proc2 from being altered by proc3?

ans: $t2 and $a03

Sra $fp $s2 $s3 $t0 $t1 local var "i" arg[4] $ra $fp $s0 $s1 $a0 $t2 arg[5] arg[4] proc1's stack frame proc2's stack frame Sra $fp $s2 $s3 $t0 $t1 local var "i" arg[4] $ra $fp $s0 $s1 $a0 $t2 arg[5] arg[4] proc1's stack frame proc2's stack frame

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!