Question: int mat 1 [ M ] [ N ] ; int mat 2 [ N ] [ M ] ; int sum _ element (
int mat M N ;
int mat N M ;
int sumelement int i int j
return mat i j mat i j ;
Suppose the above code generates the following assembly code:
; on entry i is in edi j is in esi
; movslq converts long to quad
; leaq offset R R I computes address I R R offset
; sal is a shift left
sumelement :
movslq esi rsi
movslq edi rdi
leaq rdi rdi rax
leaq rdi rax rdx
addq rsi rdx
leaq rdi rdi rcx
movq rcx rax
salq $ rax
subq rdi rax
addq rsi rax
movl mat rax eax
addl mat rdx eax
ret
What is the value of M
What is the value of N
Due to a bug, the program tried to reference mat Which element of mat will
actually be accessed?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
