Java Reference
In-Depth Information
Exercises
1. Show the frame layout corresponding to the following C function:
int f(int a, char *b){
char c;
double d[10];
float e;
...
}
Assume control information requires 3 words and that f's return value
is left on the stack. Be sure to show the o
set of each local variable in the
frame and be sure to provide for proper alignment (integers and floats
on word boundaries and doubles on doubleword boundaries).
ff
2. Local variables are normally allocatedwithin a frame, providing for auto-
matic allocation and deallocation when a frame is pushed and popped.
Under what circumstance must a local variable be dynamically allo-
cated? Are there any advantages to allocating a local variable statically
(i.e., giving it a single fixed address)? Under what circumstances is static
allocation for a local permissible?
3. Using the code below, show the sequence of frames, with dynamic links,
on the stack when r(3) is executed assuming we start execution (as
usual) with a call to main().
r(flag){
printf("Here !!!\n"); }
q(flag){
p(flag+1); }
p(int flag){
switch(flag){
case 1: q(flag);
case 2: q(flag);
case 3: r(flag); }
main(){
p(1); }
 
Search WWH ::




Custom Search