I'm trying to improve my assembly programming, and I've come across this exercise for deriving the value of the parameters in this function, but I am unsure how I should go about doing it using the assembly code given.
This is the assembly code which I am confused about (tried commenting some lines):
arrayfunc:
leaq 15992(%rdx),%rax // get 1999th element frm Array2
leaq -8(%rdx),%r10 //start of Array2
movq %rcx,%r9 // store address of Array1 in rcx into r9
.L2:
leaq -400(%rdx), %r8 //Array2 - 50longs? but why minus 50longs
movq %r9,%rdx //move address in Array1[i][j] into rdx
.L3: //inner loop
movslq (%rdx),%rcx //move value in Array1[i][j] into rcx
subq $8,%rax // increment j so becomes Array2[M-1-i][N-1-2j]
addq $4,%rdx //increment address to Array1[i][2j]
movq %rcx,8(%rax)// what does this line do
cmpq %r8,%rax //compare j<N
jne .L3
addq $200,%r9 //Not sure what this line does with the 200
cmpq %r10,%rax
jne .L2
ret
And this is the C code given:
void arrayfunc(int Array1[M][N], long Array2[M][N])
{
long i,j;
for(i=0;i<M;++i)
for(j=0;j<N;++j)
{
Array2[M-1-i][N-1-j] = Array1[i][j];
}
}
Could someone teach me how to intepret the asm correctly so that I can derive the value of M and N accurately? I'm having difficulty with interpreting the lines (not sure if I commented correctly but there are some lines I am really not sure what's happening as indicated)
Please help me understand this asm better (commenting the code would help immensely) as I really don't know how to go about finding the M and N values.
Any and all help is appreciated.