Question: Problem 1 This problem will have you draw what gets placed on the stack by the following code. Draw the stack at the following point(s):
Problem 1 This problem will have you draw what gets placed on the stack by the following code. Draw the stack at the following point(s):
Before foo() starts execution, so after the call in main is executed but before the first instruction of foo has begun
Before bar() starts execution, so after the call in foo is executed but before the first instruction of bar has begun
When the most information is on the stack, so sometime during bar when the most information has been placed on the stack.
main: .LFB0: pushq %rbp movq %rsp, %rbp subq $16, %rsp movl $0, %eax call foo movl %eax, -4(%rbp) movl -4(%rbp), %eax movl %eax, %esi movl $.LC0, %edi movl $0, %eax call printf movl $0, %eax leave ret foo: pushq %rbp movq %rsp, %rbp subq $16, %rsp movl $27, -4(%rbp) movl -4(%rbp), %eax subl $1, %eax movl %eax, %edi movl $0, %eax call bar movl -4(%rbp), %eax addl $1, %eax leave ret bar: pushq %rbp movq %rsp, %rbp movl %edi, -20(%rbp) movl $13, -4(%rbp) movl -4(%rbp), %eax leal (%rax,%rax), %edx movl -20(%rbp), %eax addl %eax, %edx movl %edx, %eax addl %eax, %eax addl %edx, %eax popq %rbp ret
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
