Problem

Figure 3.54(a) shows the code for a function that is similar to function vfunct (Figure...

Figure 3.54(a) shows the code for a function that is similar to function vfunct (Figure 3.43(a)). We used vfunct to illustrate the use of a frame pointer in man-aging variable-size stack frames. The new function aframe allocates space for local

array p by calling library function alloca. This function is similar to the more commnonly used function manoc, except that it allocates space on the run-time stack. The space is automatically deallocated when the executing procedure returns.

Figure 3.54(b) shows the part of the assembly code that sets up the frame pointer and allocates space for local variables i and p. It is very similar to the corresponding code for vframe .Let us use the same notation as in Problem 3.49: The stack pointer is set to values s1 at line 4 and s2 at line 7. The start address of array p is set to value p at line 9. Extra space e2 may arise between s2 and p, and extra space e1 may arise between the end of array p and s1.

A. Explain, in mathematical terms, the logic in the computation of s2.

B. Explain, in mathematical terms, the logic in the computation of p.

C. Find values of n and si that lead to minimum and maximum values of e1.

D. What alignment properties does this code guarantee for the values of s2 and p?

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search