The syntax of a union declaration is identical to

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: ied to register %eax by the following code: A in %eax, i in %edx, j in %ecx 1 2 3 4 array element D[i][j] is at memory address ÜD · Ä´ ¡ · µ , where Ä is the size of data type Ì in bytes. sall leal leal movl $2,%ecx (%edx,%edx,2),%edx (%ecx,%edx,4),%edx (%eax,%edx),%eax j*4 i*3 j * 4 + i * 12 Read Å Ñ ÜA · ´¿ ¡ ·µ Practice Problem 3.19: Consider the source code below, where M and N are constants declared with #define. 1 int mat1[M][N]; 148 2 3 4 5 6 7 CHAPTER 3. MACHINE-LEVEL REPRESENTATION OF C PROGRAMS int mat2[N][M]; int sum_element(int i, int j) { return mat1[i][j] + mat2[j][i]; } In compiling this program, GCC generates the following assembly code: 1 2 3 4 5 6 7 8 9 movl movl leal leal subl addl sall movl addl 8(%ebp),%ecx 12(%ebp),%eax 0(,%eax,4),%ebx 0(,%ecx,8),%edx %ecx,%edx %ebx,%eax $2,%eax mat2(%eax,%ecx,4),%eax mat1(%ebx,%edx,4),%eax Use your reverse engineering skills to determine the values of M and N based on this assembly code. 3.8.5 Fixed Size Arrays The C compiler is able to make many optimizations for c...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online