16.4.2 [first part, with stuff as a global var] stuff[i].str[j] = '\0'; # stuff[i] # need to compute the displacement from the base # of stuff to stuff[i] # the displacement/offset is (i * sizeof(struct X)) movl $X_size,%eax movl i(%ebp),%ebx mull %ebx # eax now has the offset to stuff[i] from stuff addl $stuff,%eax # eax is the address of stuff[i] addl $X_str,%eax # eax is the address of stuff[i].str addl j(%ebp),%eax # eax is the address of stuff[i].str[j] movb $0,(%eax) # stuff[i].str[j] = 0; ====================================================== for the homework assignment: int isctrl(char ch) { return (ch >= 0) && (ch <= 31) ? 1 : 0; } int isctrl(char ch) { if (ch >= 0) { if (ch <= 31) { return 1; } } return 0; } void update(char *ptr) { *ptr = *ptr + 17; } int isctrl(char ch) { if ((ch >= 0) and (ch <= 31)) return 1; else return 0; } void update(char *ptr) { *ptr += 17; } int main(void) { char state, ch, newch; int numread; state = 0; do { numread = read(0, &ch, 1); if (numread == 1) { newch = crypt(ch, &state); write(1,&newch,1); } } while (numread <> 0); }