Question: Procedures often need to allocate memory for local variables and perhaps space to save registers so they can pass parameters to other procedures. This space
Procedures often need to allocate memory for local variables and perhaps space to save registers so they can pass parameters to other procedures. This space is allocated on the stack.
The general format of a stack frame is illustrated in Figure on page of the text.
Figure
The procedure may need to save registers so it can set up calls to other procedures that require different parameters. It may also require local variables that cannot be maintained in registers, and may also require space for more than six procedure parameters.
The space for a procedures stack frame is allocated by simply subtracting the appropriate value from rsp Individual elements of the frame are accessed by indexed references based on rsp
Consider the following function and the function that calls it:
long arraysum int parray, int arraysize
long sum ;
while arraysize
sum parray;
return sum;
long caller void
int array;
int asize ;
long sum;
sum arraysum array asize;
return sum;
Below is the assembly code. Note that caller allocated bytes of stack for local variables, the element integer array and apparently sum, even though its never stored in memory.
Drag the correct register to the appropriate location in the code below. Not all labels will be used.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
