Question: A function test_one has the following overall structure: Reverse engineer the operation of this code and then do the following: A. Determine what loop translation

A function test_one has the following overall structure:

short test_one(unsigned short x) { short val = 1; while (...) { } The GCC C compiler generates the following

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

A. Determine what loop translation method was used.

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

C. Describe in English what this function computes.

short test_one (unsigned short x) { short val = 1; while (...) { } The GCC C compiler generates the following assembly code: short test_one(unsigned short x) x in %rdi 1 2 3 4 5 6 } return 7 8 9 10 11 test_one: movl jmp .L6: xorq shrq .L5: testq jne andl ret $1, %eax .L5 %rdi, %rax %rdi %rdi, %rdi .L6 $0, %eax Shift right by 1

Step by Step Solution

3.43 Rating (162 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Being able to work backward from assembly code to C code is a prime example of reverse en... 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!