We see this with variable f line 15 which is declared

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: e field declarations or the names of the fields. Practice Problem 3.21: Consider the following structure declaration. struct prob { int *p; struct { int x; int y; } s; struct prob *next; }; This declaration illustrates that one structure can be embedded within another, just as arrays can be embedded within structures, and arrays can be embedded within arrays. The following procedure (with some expressions omitted) operates on this structure: 156 CHAPTER 3. MACHINE-LEVEL REPRESENTATION OF C PROGRAMS void sp_init(struct prob *sp) { sp->s.x = ________; sp->p = ________; sp->next = ________; } A. What are the offsets (in bytes) of the following fields: p: s.x: s.y: next: B. How many total bytes does the structure require? C. The compiler generates the following assembly code for the body of sp_init: 1 2 3 4 5 6 movl movl movl leal movl movl 8(%ebp),%eax 8(%eax),%edx %edx,4(%eax) 4(%eax),%edx %edx,(%eax) %eax,12(%eax) Based on this, fill in the missing expressions in the code for sp_init. 3...
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