Question
Can someone answer and explain how or why for these problems? Thanks! __________________________________________________________________________ Suppose the C function foo has been compiled into LC-3 assembly. Consider
Can someone answer and explain how or why for these problems? Thanks!
__________________________________________________________________________
Suppose the C function foo has been compiled into LC-3 assembly. Consider the following
fragment of resulting assembly instructions:
FOO : ADD R6 , R6 , # -1
ADD R6 , R6 , # -1
STR R7 , R6 , #0
ADD R6 , R6 , # -1
STR R5 , R6 , #0
ADD R5 , R6 , # -1
ADD R6 , R6 , # -4
How many local variables does foo have?
_____________________________________________
Consider the following C program :
# include < stdio .h >
int foo(int);
int bar(int);
int main() {
int a = 1, b = 2;
a = foo(a);
b = bar(b);
printf(" a : %d , b : % d \ n ", a, b);
return 0;
}
int foo(int x) {
int y = 2;
return y + x;
}
int bar(int x) {
int z;
return z + x;
}
What is the(expected) printed output of this program ? Draw the runtime stack.
What is the value of the local variable z when bar begins executing ?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started