Question: A function test_two has the following overall structure: Reverse engineer the operation of this code and then do the following: A. Use the assembly-code version

A function test_two has the following overall structure:

short test_two (unsigned short x) { short val = 0; short i; for (...; ...; ... ) { } 1 2 3 5 6 7 8 9 10 11 12

Reverse engineer the operation of this code and then do the following:

A. Use the assembly-code version to fill in the missing parts of the C code.

B. Explain why there is neither an initial test before the loop nor an initial jump to the test portion of the loop.

C. Describe in English what this function computes.

short test_two (unsigned short x) { short val = 0; short i; for (...;...; ... ) { } 1 2 3 5 6 7 8 9 10 11 12 } return val; The GCC C compiler generates the following assembly code: test fun_b(unsigned test x) x in %rdi test_two: movl movl .L10: movq andl addq orq shrq addq jne rep: ret $1, %edx $65, %eax %rdi, %rcx $1, %ecx %rax, %rax %rcx, %rax %rdi $1, %rdx .L10 Shift right by 1

Step by Step Solution

3.36 Rating (149 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

This problem is trickier than Problem 326 since the code within ... 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 Computer Systems A Programmers Perspective Questions!

Q:

\f