double A[50]; int B[10][50]; char C[10][20][5];
What is the address of the following elements:
| Register | holds: |
| %edx | &B |
| %ecx | i |
| %ebx | j |
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;
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
struct s1 { struct s2 { union u1 {
char a[3]; struct s1 *d; struct s1 *h;
union u1 b; char e; struct s2 *i;
int c; int f[4]; char j;
}; struct s2 *g; };
};
You may find it helpful to diagram these data structures before considering the code below.For each IA32 assembly code sequence below on the left, fill in the missing portion of corresponding C code on the right.
proc1: int proc1(struct s2 *x) {
pushl %ebp
movl %esp,%ebp return x->____________________
movl 8(%ebp),%eax
movl 12(%eax),%eax }
movl %ebp,%esp
popl %ebp
ret
proc2: int proc2(struct s1 *x) {
pushl %ebp
movl %esp,%ebp return x->________________
movl 8(%ebp),%eax
movl 4(%eax),%eax }
movl 20(%eax),%eax
movl %ebp,%esp
popl %ebp
ret
proc3: char proc3(union u1 *x) {
pushl %ebp
movl %esp,%ebp return x->___________________
movl 8(%ebp),%eax
movl (%eax),%eax }
movsbl 4(%eax),%eax
movl %ebp,%esp
popl %ebp
ret
proc4: char proc4(union u1 *x) {
pushl %ebp
movl %esp,%ebp return x->_________________
movl 8(%ebp),%eax
movl (%eax),%eax }
movl 24(%eax),%eax
movl (%eax),%eax
movsbl 1(%eax),%eax
movl %ebp,%esp
popl %ebp
ret