Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

Students also viewed these Databases questions