Question: 7. Given the following x86-64 assembly language code for a recursive function f() produced using the -og option to gcc: f: movl %esi, %eax

7. Given the following x86-64 assembly language code for a recursive function

 

7. Given the following x86-64 assembly language code for a recursive function f() produced using the -og option to gcc: f: movl %esi, %eax testl %edi, %edi. jg .L7 rep ret .L7: subq $8, %rsp leal subl 1(%rsi), %esi $1, %edi call f addq ret $8, %rsp a. Annotate the above assembly code. For instructions where it makes sense, your annotations should be of the form machineElement = srcExpr where machine Element should specify a x86-64 register and srcExpr should be an expression involving made-up names for variables from a C program. You should annotate the arguments to f() as well. b. Write a C function which is equivalent to the above assembly code. Ideally, the C function should compile into the above code, but it is sufficient that it merely be semantically equivalent. c. Give a simple characterization of what this function computes. d. Give a non-recursive C function which computes the same result. 15-points

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a Annotated x8664 assembly code assembly f movl esi eax Move the value of the second para... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!