May 4th, 2013, 04:29 PM
Consider the following code (help please)
Im working on some homework and have gotten stuck.
Here is the problem I am working on.
Consider the following source code, where R, S, and T are constants declared with
In compiling this program, gcc generates the following assembly code:
int store_ele(int i, int j, int k, int *dest)
*dest = A[i][j][k];
i at %ebp+8, j at %ebp+12, k at %ebp+16, dest at %ebp+20
1 movl 12(%ebp), %edx
2 leal (%edx,%edx,4), %eax
3 leal (%edx,%eax,2), %eax
4 imull $99, 8(%ebp), %edx
5 addl %edx, %eax
6 addl 16(%ebp), %eax
7 movl A(,%eax,4), %edx
8 movl 20(%ebp), %eax
9 movl %edx, (%eax)
10 movl $1980, %eax
A. Extend Equation 3.1 from two dimensions to three to provide a formula for
the location of array element A[i][j][k].
B. Use your reverse engineering skills to determine the values of R, S, and T
based on the assembly code.
I kind of know how to read this, I know that they are all being stored as a group under A, and j gets moved to the edx register in line 1.
However when it comes to the actual questions I dont know what it means by Extend equation 3.1 or how to come up with a formula for the location of A[i][j][k]. To me it appears that the final value is moved to the eax register in the last line.
Moving on to B, I do not know how to tell which values are corresponding to R, S, and T because you are not give initial locations of these variables.
Any answers, suggestions, or assistance would be greatly appreciated, thank you very much for your time and help.
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!