Answered step by step
Verified Expert Solution
Question
1 Approved Answer
NOTE: This is part 1 of a 3 part problem. All the while loop questions refer to the same C code and the same assembly
NOTE: This is part 1 of a 3 part problem. All the while loop questions refer to the same C code and the same assembly code, but ask you to determine a different missing expression. It is probably easiest if you try to determine all 3 expressions first, and then go back and select the best answer in each of the 3 quiz questions. Below is a function written in C with three missing expressions (init, test, and update) Below that is the result of compiling the original function (before I removed the expressions). Which of the choices below is the missing init expression that would lead to the assembly below? int g( int x, int y){ int loop_var =/ init /; int answer =0; while (/ test /){ answer += loop_var; loop_var =/ update / \} \} return answer +x; \} leal (\%rdi, \%rdi), \%edx movl \$0,\%eax cmpl \%esi, \%edx jle . L6 addl \%edx, \%eax subl \$4,\%edx cmpl \%edx,\%esi jl .L9 addl \%edi, \%eax ret loop_var =0 loop_var =4 NOTE: This is part 2 of a 3 part problem. All the while loop questions refer to the same C code and the same assembly code, but ask you to determine a different missing expression. It is probably easiest if you try to determine all 3 expressions first, and then go back and select the best answer in each of the 3 quiz questions. Below is a function written in C with three missing expressions (init, test, and update) Below that is the result of compiling the original function (before I removed the expressions). Which of the choices below is the missing test expression that would lead to the assembly below? int g (int x, int y){ int loop_var =/ init */; int answer =0; while (/ test /){ answer += loop_var; loop_var =/ update /; \} return answer +x \} leal (\%rdi,\%rdi), \%edx movl \$0, \%eax cmpl \%esi, \%edx jle .L6 addl \%edx, \%eax subl \$4, \%edx cmpl \%edx, \%esi jl .L9 addl \%edi, \%eax ret loop_var x loop_var y NOTE: This is part 3 of a 3 part problem. All the while loop questions refer to the same C code and the same assembly code, but ask you to determine a different missing expression. It is probably easiest if you try to determine all 3 expressions first, and then go back and select the best answer in each of the 3 quiz questions. Below is a function written in C with three missing expressions (init, test, and update) Below that is the result of compiling the original function (before I removed the expressions). Which of the choices below is the missing update expression that would lead to the assembly below? int g( int x, int y){ int loop_var =/ init /; int answer =0; while (/ test /){ answer += loop_var; loop_var =/ update /; \} return answer +x; leal (\%rdi,\%rdi), \%edx movl \$0, \%eax cmpl \%esi, \%edx jle . L6 addl \%edx, \%eax subl \$4,\%edx cmpl \%edx, \%esi jl.L9 addl \%edi, \%eax ret
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started