Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 4 (Recursion) (20 points) Amelia really likes recursive functions and ha

ID: 3601060 • Letter: P

Question

Problem 4 (Recursion) (20 points) Amelia really likes recursive functions and has written a function fun times that produces the following assembly code when compiled using GCC: fun times pushq %rbp mova subq $32 ,%rsp movg movl %esi,-28 (%rbp) cmp1 $0,-28 (rbp) jne L movl $0, eax 27 29 30 rdi, -24 (%rbp) 32 34 2 36 37 38 39 40 movl $0, -4 (%rbp ) 5 4 (%rbp) , movl movs1q %eax , %rax movg addq movzbl rax), eax movsbl al, %eax addl addl %eax 47 $1, -4 (%rbp. 4 %eax movl pl -4 (%rbp) , 49 50 movl leal movg movl movg call movl movl addl 52 28 ( % rbp) , eax 54 24 ( rbp) , % rax %edx , %esi 56 57 58 59 60 fun times 8 (%rbp) , %eax s e 3 62 63 leave ret A. What does fun times do? Demonstrate the logic either in C code or in pseudocode B. How many bvtes is allocated on the stack with each call to fun times? C. Where is the result (i.e., return value) stored?

Explanation / Answer

A. The function fun_times produces the above assembly code when compiled using GCC.It is a function used here and used as the code as above in assemblyn level language.This function includes various sub functions which perform the task individually like push,move,subtract and compare.This collects all the other functions to be used un this in an logical and appropriate manner.

B. Three bytes are allocated on the stack with eachcall to fun_times.

C. The result is stored in L3.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote