What does this code do?
An array of
array[x][y] form is accessed here. Try to determine the dimensions of the array, at least partially, by finding y.
_array$ = 8 _x$ = 12 _y$ = 16 _f PROC mov eax, DWORD PTR _x$[esp-4] mov edx, DWORD PTR _y$[esp-4] mov ecx, eax shl ecx, 4 sub ecx, eax lea eax, DWORD PTR [edx+ecx*8] mov ecx, DWORD PTR _array$[esp-4] fld QWORD PTR [ecx+eax*8] ret 0 _f ENDP
At first I think there is a mistake in the question. Because I only see three variables here, one for array address, the one x and one y, so I assume it's actually a 2d array of double, not a 3d as in "An array of
Then I was stuck because eventually the program loads
array[8y+192x], and x and y can be anything.
So I figured this must be a 3d array of double, with the third dimension given. I still couldn't figure it out so I tried to write my own program and use Godbolt to give me assembly. After a few trials I got something pretty close to the original program:
However I'm still having difficulty to match my program with the original question. I think I'm pretty close but how do I proceed from here? I have a hunch that y is also 24 in the original question, but not 100% sure.