CS360 Midterm -- October 18, 1999. Question 2
Behold the following piece of code:
int A;
int f1(int i, int j)
{
j += i;
return j;
}
main()
{
int k;
k = 5;
A = f1(k+5);
}
Part 1
Turn the above code into assembly code.
Part 2
Draw the state of the stack and registers
just before the return statement
in f1(). If you need to make up
some values for the stack pointer, assume
that when main() first executes,
the stack pointer is 0xeffff87c.
Part 3
When main() returns, what are the values of A and k?