Washington nested array row access code int

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: shington Nested Array Row Access   Row vectors   T A[R][C]: A[i] is array of C elements   Each element of type T requires K bytes   StarNng 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 Nested Arrays A[R-1] A [i] [C-1] A • • • [R-1] [0] • • • A+(R-1)*C*4 A [R-1] [C-1] University of Washington Nested Array Row Access Code int *get_sea_zip(int index) { return sea[index]; } Nested Arrays #define zip_dig {{ 9, { 9, { 9, { 9, PCOUNT 4 sea[PCOUNT] = 8, 1, 9, 5 }, 8, 1, 0, 5 }, 8, 1, 0, 3 }, 8, 1, 1, 5 }}; University of Washington Nested Array Row Access Code int *get_sea_zip(int index) { return sea[index]; } #define zip_dig {{ 9, { 9, { 9, { 9, PCOUNT 4 sea[PCOUNT] = 8, 1, 9, 5 }, 8, 1, 0, 5 }, 8, 1, 0, 3 }, 8, 1, 1, 5 }}; # %eax = index leal (%eax,%eax,4),%eax # 5 * index leal sea(,%eax,4),%eax # sea + (20 * index)   Row Vector   sea[index] is array of 5 ints (a zip_dig data type)   StarNng address sea+20*index   IA32 Code   Computes and returns address   Compute as sea+4*(index+4*index)=sea+20*index Nested Arrays University of Washington Nested Array Row Access int A[R][C]; A[0] A [0] [0] A • • • A[i] A [0] [C-1] • • • A • • • [ i ] • • • [j] A + i*C*4 Nested Arrays A[R-1] A • • • [R-1] [0] • • • A + (R-1)*C*4 A [R-1] [C-1] University of Washington Nested Array Row Access   Array Elements   A[i][j] is element of type T, which requires K bytes   Address A + i * (C * K) + j * K = A + (i * C + j)* K int A[R][C]; A[0] A [0] [0] A • • • A[i] A [0] [C-1] • • • A • • • [ i ] • • • [j] A[R-1] A • • • [R-1] [0] A + i*C*4 A + i*C*4 + j*4...
View Full Document

Ask a homework question - tutors are online