This generates the following assembly



int mat1[M][N];
int mat2[N][M];
int copy_element(int i, int j)
{
mat1[i][j] = mat2[j][i];
}

This generates the following assembly code:
copy_element:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 8(%ebp),%ecx
movl 12(%ebp),%ebx
movl %ecx,%edx
leal (%ebx,%ebx,8),%eax
sall ,%edx
sall ,%eax
subl %ecx,%edx
movl mat2(%eax,%ecx,4),%eax
sall ,%edx
movl %eax,mat1(%edx,%ebx,4)
movl -4(%ebp),%ebx
movl %ebp,%esp
popl %ebp
ret

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: This generates the following assembly
Reference No:- TGS087463

Expected delivery within 24 Hours