The following program has been compiled to jassem assembly code. At the point where the procedure b() calls the instruction ret, the value of the frame pointer is 0x100340
.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
int a(int j, int k, int l)
{
int m[2];
m[0] = l;
m[1] = j + k + l;
return m[0] + m[1];
}
int b(int x, int y, int *p)
{
int *k;
k = p+x;
y = *k;
return y;
}
int main()
{
int i;
i = a(1, 2 ,3) + b(7 ,8 ,&i);
return i;
}
Please answer the following questions about the stack at the point when b() calls ret.
You don’t have to create assembly code for this – you simply need to know how it works. When I say “What is at address x”, you should answer something like “in a(0)” or “frame pointer for main()” .
If you can’t know then answer “unknown”.
Question 1: What is value of stack pointer?
Question 2: What is at address 0x10033c
?
Question 3: What is at address 0x100340
?
Question 4: What is at address 0x100344
?
Question 5: What is at address 0x100348
?
Question 6: What is at address 0x10034c
?
Question 7: What is at address 0x100350
?
Question 8: What is at address 0x100354
?
Question 9: What is at address 0x100358
?
Question 10: What is at address 0x10035c
?