# Ng address a i c k int arc a0 a 0 0 a

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

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cated con?guously “Row- Major” ordering of all elements guaranteed 9 MULTIDIMENSIONAL (NESTED) ARRAYS ¢༊  Declara?on A[0][0] T A[R][C]; ༉  2D array of data type T ༉  R rows, C columns ༉  Type T element requires K bytes ¢༊  Array Size ༉  ¢༊  • • • ••• A[0][C-1] • • • A[R-1][0] • • • A[R-1][C-1] R * C * K bytes Arrangement ༉  Row- Major Ordering int A[R][C]; A [0] [0] A A • • • [0] [1] [C-1] [0] A • • • [1] [C-1] 4*R*C Bytes • • • A A [R-1] • • • [R-1] [0] [C-1] 10 NESTED ARRAY ROW ACCESS ¢༊  Row Vectors ༉  ༉  ༉  A[i] is array of C elements Each element of type T requires K bytes Star?ng address A + i * (C * K) int A[R][C]; A[0] A [0] [0] A • • • A[i] A [0] [C-1] • • • A [i] [0] • • • A+(i*C*4) A[R-1] A [i] [C-1] A • • • [R-1] [0] • • • A [R-1] [C-1] A+((R-1)*C*4) 11 int *get_pgh_zip(int index) { return pgh[index]; } #define PCOUNT 4 zip_dig pgh[PCOUNT] = {{1, 5, 2, 0, 6}, {1, 5, 2, 1, 3 }, {1, 5, 2, 1, 7 }, {1, 5, 2, 2, 1 }}; # %eax = index leal (%eax,%eax,4),%eax # 5 * index leal pgh(,%eax,4),%eax # pgh + (20 * index) ¢༊  Row Vector ༉  ༉  ¢༊  pgh[index] is array of 5 int’s Star?ng address pg...
View Full Document

Ask a homework question - tutors are online