Struct prob int p struct int x int y s struct prob

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: red in memory in “row major” order, meaning all elements of row 0, followed by all elements of row 1, and so on. Element A[0][0] A[0][1] A[0][2] A[1][0] A[1][1] A[1][2] A[2][0] A[2][1] A[2][2] A[3][0] A[3][1] A[3][2] ÜA ÜA · ÜA · ÜA · ½¾ ÜA · ½ ÜA · ¾¼ ÜA · ¾ ÜA · ¾ ÜA · ¿¾ ÜA · ¿ ÜA · ¼ ÜA · Address This ordering is a consequence of our nested declaration. Viewing A as an array of four elements, each of which is an array of three int’s, we first have A[0] (i.e., row 0), followed by A[1], and so on. To access elements of multidimensional arrays, the compiler generates code to compute the offset of the desired element and then uses a movl instruction using the start of the array as the base address and the (possibly scaled) offset as an index. In general, for an array declared as: Ì D[Ê][ ]; As an example, consider the ¢ ¿ integer array A defined earlier. Suppose register %eax contains ÜA , that %edx holds i, and %ecx holds j. Then array element A[i][j] can be cop...
View Full Document

Ask a homework question - tutors are online