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

Please provide explanation along with the answers. Thank you. Look at the C code

ID: 3890532 • Letter: P

Question

Please provide explanation along with the answers. Thank you.

Look at the C code below and pick the correct option to fill out the blanks in the corresponding assembly code. Options for blanks: %eax, %ebx, %ecx, %eax, %esi, %edi, %rsp, %rbp, add, sub, imul, jmp, je, jne, js, jle, jge, jl, jg, cmpl, lea, mov. Options may be used more than once. Each blank is worth 4 points C Code: mysteryFunction: int mysteryFunction (int x,char c) push %rbp signed int result = 0; unsigned short int i; char b[5]; mov mov mov mov mov! movw %edi,-0x14 (%rbp) %esi, %eax %al,-0x18(%rbp) $0x0,-0x4 (%rbp) $0x1,-0x6 (%rbp) 5 for (i=1; i= 0){ .L2 result = result + 1*1; -0x18 (%rbp ) , %eax movsbl test movzwl $0x61, %eax else %eax, %eax 3 -0x6 (%rbp) , %eax -0x6 (%rbp) , %eax %eax, %eax %eax,-0x4 (%rbp) 4 result result + 1; movzwl b[1-1] = result + 'a'; add jmp return result; 3 movzwl add jmp -0x6 (%rbp ) , %eax %eax,-0x4 ( L4 4 movzwl mov add mov movsig mov movzwl -0x6 (%rbp) , %eax -0x1 ( % rax) , %ecx -0x4 (%rbp) , %eax $0x61, %eax, %edx %ecx, % rax %dl,-0x10( -0x6 (%rbp) , %eax $0x1, %eax %ax,-0x6 (%rbp) , %rax, 1) mov jmp L5 .L5 movzwl cmp -0x6 (%rbp) , %eax -0x14 ( % rbp) , %eax 2 -0x4 (%rbp) , %eax mov pop retq % rbp

Explanation / Answer

Answers are given according to their sequence

1) je :- is used for equal so variable is stored with value 0

2) %rbp :- is used for allocating value 1 to i variable.

3) %rsp:- is used for storing value to result variable.

4) mov:- is used for transfering variable address to registers.

5) %rsp :- for storing value in result variable.

6) %ebx :- as we have to get the value of another variable address (%eax indicate first variable address).

7) %rbp :- is used for storing addition value to array of b with index i-1.

8) sub:- to indicate minus one index in array of b.

9) add:- for incrementing counter variable.

9) je :- is used for giving incremented value to variable i.

10) je:- to allocate the value to variable.

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