Question: I code use some help with this coding question: 2. Analyze the x86-64 assembly given below. Q2: cmpl %esi, %edi # The parameters are passed

I code use some help with this coding question:

2. Analyze the x86-64 assembly given below.

Q2: cmpl %esi, %edi # The parameters are passed in registers. movl %esi, %eax cmovge %edi, %eax #This is called a conditional move. ret

Note: this function has been optimized and doesn't manipulate the stack. Registers store the parameters, recall which registers hold parameters.

a) [20 points] Assume the function is named Q2. Suppose that any parameters are named P1, P2, etc., in the order the parameters would be listed in the C code. Suppose the local variables are called L1, L2, etc., in the order they occur in the assembly code.

Write C code for the function that could have yielded the x86-64 assembly code given above, in the provided .c file. Your final answer must not include any goto statements! Be advised: you may derive a perfectly acceptable answer and find that when you compile it you get slightly different assembly code. Minor differences should be expected, so don't tweak your C code trying to replicate the assembly code exactly.

#include #include

// // // // int Q2(int P1, int P2) { // Reverse engineered code here. return 0; }

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!