324_Book

# In this particular problem there are no misses of any

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: int val) { int *Aptr = &amp;A[0][0] + 255; int cnt = N-1; do { *Aptr = val; Aptr -= (N+1); cnt--; } while (cnt &gt;= 0); } The relation to the assembly code can be seen via the following annotations: 1 2 3 4 5 6 7 8 9 10 movl 12(%ebp),%edx movl 8(%ebp),%eax movl \$15,%ecx addl \$1020,%eax .p2align 4,,7 .L50: movl %edx,(%eax) addl \$-68,%eax decl %ecx jns .L50 Get val Get A i=0 Aptr = &amp;A[0][0] + 1020/4 loop: *Aptr = val Aptr -= 68/4 i-if i &gt;= 0 goto loop Observe how the assembly code program starts at the end of the array and works backward. It decrements the pointer by 68 ( ½ ¡ ), since array elements A[i-1][i-1] and A[i][i] are spaced N+1 elements apart. Problem 3.21 Solution: [Pg. 155] This problem gets you to think about structure layout and the code used to access structure ﬁelds. The structure declaration is a variant of the example shown in the text. It shows that nested structures are allocated by embedding the inner structures within the outer ones. A. The layout of the structure is as follows: Offset Contents B. 16 bytes 0 p 4 s.x 8 s.y 1...
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