L59 leal eaxeax4edx eaxeax4edx movl ecxeax ecxeax addl

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: ComputaMons   10*zi + *z implemented as *z + 2*(5*zi)   z++ increments by 4 int zd2int(zip_dig z) int zd2int(zip_dig z) { int zi = 0; zi 0; int *zend = z + 4; *zend 4; do { zi = 10 * zi + *z; 10 zi *z; *z; z++; } while(z <= zend); zend); return zi; zi; } # %ecx = z xorl %eax,%eax %eax,%eax leal 16(%ecx),%ebx 16(%ecx),%ebx .L59: leal (%eax,%eax,4),%edx (%eax,%eax,4),%edx movl (%ecx),%eax (%ecx),%eax addl $4,%ecx $4,%ecx leal (%eax,%edx,2),%eax (%eax,%edx,2),%eax cmpl %ebx,%ecx %ebx,%ecx jle .L59 .L59 Arrays # zi = 0 # zend = z+4 z+4 # # # # # # zi + 4*zi = 5*zi *z z++ zi = *z + 2*(5*zi) *z 2*(5*zi) z : zend if <= goto loop goto loop University of Washington Arrays & Other Data Structures           Array allocaMon and access in memory MulM ­dimensional or nested arrays MulM ­level arrays Other structures in memory Data structures and alignment Nested Arrays University of Washington Nested Array Example #define zip_dig {{ 9, { 9, { 9, { 9, Remember, T A[N] is an array with N elements of type T PCOUNT 4 sea[PCOUNT] = 8, 1, 9, 5 }, 8, 1, 0, 5 }, 8, 1, 0, 3 }, 8, 1, 1, 5 }}; Nested Arrays University of Washington Nested Array Example #define zip_dig {{ 9, { 9, { 9, { 9, Remember, T A[N] is an array with N elements of type T PCOUNT 4 sea[PCOUNT] = 8, 1, 9, 5 }, 8, 1, 0, 5 }, 8, 1, 0, 3 }, 8, 1, 1, 5 }}; sea[3][2]; 98195981059810398115 76     96 116 “Row ­major” ordering of all elements This is guaranteed Nested Arrays 136 156 University of Washington MulMdimensional (Nested) Arrays   DeclaraMon           T A[R][C]; 2D array of data type T R rows, C columns Type T element requires K bytes Array size? Nested Arrays A[0][0] • • • ••• A[0][C-1] • • • A[R-1][0] • • • A[R-1][C-1] University of Washington MulMdimensional (Nested) Arrays   DeclaraMon           T A[R][C]; 2D array of data type T R rows, C columns Type T element requires K bytes Array size A[0][0] • • • ••• 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 Nested Arrays • • • A A [R-1] • • • [R-1] [0] [C-1] University of Wa...
View Full Document

This document was uploaded on 04/04/2014.

Ask a homework question - tutors are online