2-Below is the C code and corresponding assembly code: int a[M][N]; int b[N][M];
ID: 3713349 • Letter: 2
Question
2-Below is the C code and corresponding assembly code:
int a[M][N];
int b[N][M];
int F1(int i, int j) {
a[i][j] = b[j][i];
return(i);
}
F1:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax
sall $3, %eax
movl %eax, %ecx
addl 12(%ebp), %ecx
movl 12(%ebp), %edx
movl %edx, %eax
sall %eax
addl %edx, %eax
leal 0(,%eax,4), %edx
addl %edx, %eax
addl 8(%ebp), %eax
movl b(,%eax,4), %eax
movl %eax, a(,%ecx,4)
movl 8(%ebp), %eax
leave
ret
You job is to determine what M and N
M =
N =
(find M and N like whose I and J )
(In COMPUTER SYSTEM LANGUAGE)
assembly
Explanation / Answer
IN assembly language ;
M = 8(%ebp) = %ebp + 8
N = 12(%ebp) = %ebp + 12
Explanation :-
arguements are passed to function through stacks.So,after passing arguements into stack ; N is pushsed first and then M .But; after calling we have to also push the return address into stack which further increases the position of M and N in stack.So,due to which following results arise
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.