CS 367 HW #4

  1. Consider the given C array declarations (and sizes from Fig 3.1 of your text).
    double A[50];
    int B[10][50];
    char C[10][20][5];
    
  2. Consider the following datatype definitions on an IA32 (x86) machine.
    typedef struct {				typedef union {		
       char c;					   char c;
       double *p;					   double *p;
       int i;					   int i;
       double d;					   double d;
       short s;					   short s;
    } struct1;					} union1;
    
  3. In the following problem, you are given the task of reconstructing C code based on some declarations of C structures and unions, and the IA32 assembly code generated when compiling the C code. Use the same size and alignment assumptions as question 1. Below are the data structure declarations. (Note that this is a single declaration which includes several data structures; they are shown horizontally rather than vertically simply so that they fit on one page.)
    struct s1 {			struct s2 {			union u1 {
       char a[3];	0		   struct s1 *d;	0	   struct s1 *h;	0
       union u1 b;	4		   char e;		4	   struct s2 *i;	4
       int c;	8		   int f[4];		8	   char j;		8
    };				   struct s2 *g;	24	};
    				};
    
    
    You may find it helpful to diagram these data structures before considering the code below. Offsets added above

    For each IA32 assembly code sequence below on the left, fill in the missing portion of corresponding C code on the right.