Question: 1. The C code given below produces the following x86 assembly. Draw the stack frames for each of the following, showing the relevant stack contents

1. The C code given below produces the following x86 assembly. Draw the stack frames for each of the following, showing the relevant stack contents and the addresses (write the addresses in relation to ebp, for example, ebp, ebp -4, etc.) a) Stack frame of main at calll_f b) Stack frame of function f at calll g c) Stack frame of function g after movl-40%ebp), %eax int g(int x) return x+3;) pushl %ebp movl %esp, %ebp pushl %eax movl 8(%ebp), %eax movl %eax,-4(%ebp) movl -4(%ebp), %eax addl $3, %eax addl $4, %esp popl %ebp retl int f(int x) return g(x);J t main return f(8):) pushl %ebp movl %esp, %ebp subl $8, %esp movl 8(%ebp), %eax movl %eax,-4(%ebp) movl -4(%ebp), %eax movl %eax, (%esp) call g addl $8, %esp popl %ebp retl pushl %ebp movl %esp, %ebp subl S24, %esp movl $8, %eax movl $0.4(%ebp) movi s8.1%esp) movl %eax,-8(%ebp) calll f add $24, %esp popl %ebp retl 1. The C code given below produces the following x86 assembly. Draw the stack frames for each of the following, showing the relevant stack contents and the addresses (write the addresses in relation to ebp, for example, ebp, ebp -4, etc.) a) Stack frame of main at calll_f b) Stack frame of function f at calll g c) Stack frame of function g after movl-40%ebp), %eax int g(int x) return x+3;) pushl %ebp movl %esp, %ebp pushl %eax movl 8(%ebp), %eax movl %eax,-4(%ebp) movl -4(%ebp), %eax addl $3, %eax addl $4, %esp popl %ebp retl int f(int x) return g(x);J t main return f(8):) pushl %ebp movl %esp, %ebp subl $8, %esp movl 8(%ebp), %eax movl %eax,-4(%ebp) movl -4(%ebp), %eax movl %eax, (%esp) call g addl $8, %esp popl %ebp retl pushl %ebp movl %esp, %ebp subl S24, %esp movl $8, %eax movl $0.4(%ebp) movi s8.1%esp) movl %eax,-8(%ebp) calll f add $24, %esp popl %ebp retl
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
