Question
Consider the source code below, where M and N are constants declared with #define. int array1[M][N]; int array2[N][M]; int copy(int i, int j) { array1[i][j]
Consider the source code below, where M and N are constants declared with #define.
int array1[M][N];
int array2[N][M];
int copy(int i, int j)
{
array1[i][j] = array2[j][i];
} Suppose the above code generates the following assembly code: copy:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 8(%ebp),%ecx
movl 12(%ebp),%ebx
leal (%ecx,%ecx,8),%edx
sall $2,%edx
movl %ebx,%eax
sall $4,%eax
subl %ebx,%eax
sall $2,%eax
movl array2(%eax,%ecx,4),%eax
movl %eax,array1(%edx,%ebx,4)
popl %ebx
movl %ebp,%esp
popl %ebp
ret
What are the values of M and N? Show all of your work or explain how you obtained your answer. No points will be given for just the answer without any explanation!
M = N =
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started