Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

7. You know the following assembly code snippet is from a recursive function in C. You also know that the stack contents at a particular

image text in transcribedimage text in transcribedimage text in transcribed

7. You know the following assembly code snippet is from a recursive function in C. You also know that the stack contents at a particular point in time when we are in recursive function are shown on the next page. Answer the following questions: a) how many Foo stack frames are on the stack? b) what is the retum address back to the function that called Foo for the first time? c) what is the return address back into the function Foo? d) how many bytes is in one instance of the Foo stack frame? (be sure exaplain your answer). Recall the ig instruction jumps if the result is greater than points, 5 points each for a-d 0. (20 Foo: pushq %rbp movq %rsp, %rbp subq $16, %rsp movl %edi,-4(%rbp) movq %rsi,-16(%rbp) cmpl $4,-4(%rbp) Jg .L2 movl $5, %eax mp L3 movl leal -3(%rax), %edx movq -16(%rbp), %rax movq %rax, %rsi movl %edx, %edi call Foo movq %rax, %rax movq -16(%rbp), %rax addq %rdx, %rax addq %rax,-16(%rbp) movq -16(%rbp), %rax L2: -4(%rbp), %eax L3: leave ret (gdb) x/34gx $rsp 0x7fffffffe790: 0x00007fffffffe870 0x7fffffffe7a0: 0x00007fffffffe7c0 0x7fffffffe7b0 0x000000000000000a 0x7fffffffe7c0: 0x00007fffffffe7e0 0x7fffffffe7d0 0x000000000000000a Ox7fffffffe7e0 0x00007fffffffe800 0x7fffffffe7f0: 0x000000000000000a 0x7fffffffe800: 0x00007fffffffe820 0x7fffffffe810: 0x000000000000000a Ox7fffffffe820: 0x00007fffffffe840 0x7fffffffe830: 0x000000000000000a 0x7fffffffe840: 0x00007fffffffe860 0x7fffffffe850: 0x000000000000000a 0x7fffffffe860 0x00007fffffffe880 Ox7fffffffe870: 0x00000064ffffe960 0x7fffffffe880 0x0000000000000000 0x7fffffffe890: 0x0000000000000000 0x00007fffffffe7a0 0x00000000004005a6- 0x00000055fbad2a84 0x00000000004005a6 0x00000058f7de9ff7 0x00000000004005a6 0x0000005bf7a371b8 0xeO 0 0 0 0 0 0 0 0 0 4 0 05a6_ 0x0000005ef7df0515 0:0 00 00 0 0 0 0 0 4 0 05a6_ 0x00000061ffffe874 0x00000000004005a6 0x0000006400000000 0x00000000004005fc 0x000000000000000a 0x00007ffff7a52b45 0x00007fffffffe968

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Entity Alignment Concepts Recent Advances And Novel Approaches

Authors: Xiang Zhao ,Weixin Zeng ,Jiuyang Tang

1st Edition

9819942527, 978-9819942527

More Books

Students also viewed these Databases questions

Question

denigration of emotional outbursts; being reserved;

Answered: 1 week ago