Question: Consider the following source code, where M and N are constants declared with #define: In compiling this program, gcc generates the following assembly code: Use

Consider the following source code, where M and N are constants declared with #define:

long P [M] [N]; long Q[N] [M]; long sum_element (long i, long j) { return P[i] [j] + Q[j] [i]; }

In compiling this program, gcc generates the following assembly code:

1 234 5 6 7 8 9 long sum_element (long i, long j) i in %rdi, j in %rsi sum_element: leaq subq addq leaq addq

Use your reverse engineering skills to determine the values ofM and N based on this assembly code.

long P [M] [N]; long Q[N] [M]; long sum_element (long i, long j) { return P[i][j] + Q[j][i]; }

Step by Step Solution

3.48 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

This problem requires you to work through the scaling operations to determi... 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!