Question: Please explain answer Question 6 Consider the following funtion: int recursive int n) The assembly code equivalent of the above function is recursive push %ebp

 Please explain answer Question 6 Consider the following funtion: int recursive

Please explain answer

Question 6 Consider the following funtion: int recursive int n) The assembly code equivalent of the above function is recursive push %ebp mov %esp,%ebp push %ebx sub sex 14,%esp cmpl $0x1,0x8(%ebp) je L1 cmpl $0x2,0x8(%ebp) jne L2 L1 mov 0x8 (%ebp),%eax jmp 13 L2 mov 0x8 (%ebp),%eax sub $0x1, %eax mov %eax, (%esp) call recursive mov %eax,%ebx mov 0x83 (%ebp),%eax sub $0x2,%eax mov %eax, (%esp) call recursive imul %ebx,%eax L3 add $0x14,%esp pop %ebx pop %ebp ret What would be the values returned for the code below? int ret val 1 recursive (1); int ret val 2 recursive (2); O return val 1 is 2 and return val 2 is 1 return val 1 is 1 and return val 2 is 1 return val 1 is 1 and return val 2 is 2 O return va 1 is 2 and return val 2 is 2 O return val 1 is 3 and return val 2 is 3 1 pts Question 6 Consider the following funtion: int recursive int n) The assembly code equivalent of the above function is recursive push %ebp mov %esp,%ebp push %ebx sub sex 14,%esp cmpl $0x1,0x8(%ebp) je L1 cmpl $0x2,0x8(%ebp) jne L2 L1 mov 0x8 (%ebp),%eax jmp 13 L2 mov 0x8 (%ebp),%eax sub $0x1, %eax mov %eax, (%esp) call recursive mov %eax,%ebx mov 0x83 (%ebp),%eax sub $0x2,%eax mov %eax, (%esp) call recursive imul %ebx,%eax L3 add $0x14,%esp pop %ebx pop %ebp ret What would be the values returned for the code below? int ret val 1 recursive (1); int ret val 2 recursive (2); O return val 1 is 2 and return val 2 is 1 return val 1 is 1 and return val 2 is 1 return val 1 is 1 and return val 2 is 2 O return va 1 is 2 and return val 2 is 2 O return val 1 is 3 and return val 2 is 3 1 pts

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!