Answer key for Fall 1999 practice exam. Problem 1: ********* 5 00000101 -10 11110110 64 01000000 -11 11110101 127 01111111 -128 10000000 -1 11111111 -1 11111111 1 00000001 0 00000000 Problem 2: ********* * No Counter-example: i=0 * No Counter-example: i=1, i & -i = 1 * Yes * No Counter-example: i=Tmax, k=1 * No Counter-example: i=Tmin -Tmin = Tmin * Yes * No Counter-example: i=Tmax, k=2 Problem 3: ********* a) p = head; while(p != NULL) { do_work(p); p = p->next; } b) p = head; if(p != NULL) { do { do_work(p); p = p->next; } while(p != NULL); } c) Choice 1 Problem 4: ********* a) int isNeg = (x >> 31) & (1); int isEven = !(x & 1); return (isNeg | isEven); b) No, Counter-example: x=Tmin, y = 1 (sum = Tmax) Problem 5: ********* a) -4 b) pointer needs to passed c) ebx, -8 d) n e) n f) e g) 14 Problem 6: ********* s:bytes occupied by s[0] S:bytes occupied by s[1] p:bytes used for padding a) cpppppppddddddddssSSpppp b) 24 (double member forces 8 byte alignment) c) 8 d) 16, with 3 unused bytes, Layout as follows: ddddddddssSScppp Problem 7: ********* - struct file: (field,offset,len) (epsilon,0,8) (id_number,8,4) (flags,12,4) (data,16,32) (parent,48,4) Overall: 56 bytes - struct directory (id_number, 0,4) (flags,4,4) (children,8,32) Overall: 40 bytes - union fsobject (f, 0,4) (d, 0,4) (refcount,0,4) Overall: 4 - struct kernel_object (object_type, 0,4) (obj.fso, 4,4) (obj.other, 4,4) Overall: 8 Problem 8: ********* p1: movl 8(%ebp), %eax movl 4(%eax), %aax movl 0(%eax), %ea p2: movl 8(%ebp), %eax movl 4(%eax), %eax movl 0(%eax), %eax movl 4(%eax), %eax p3: movl 8(%ebp), %eax movl 4(%eax), %eax movl 0(%eax), %eax movl 48(%eax), %eax movl 4(%eax), %eax Problem 9: ********* a) 7 b) size = 280 (276+4) c) ROW = size/(COL*element_size) ROW = 10 Problem 10: ********** for (i=0; (i