2007-03-09 Exam Solutions Datorarkitektur SUDARK, 2D4121, 2D1377 Problem 1. Expression decimal binary ----------------------------------- Zero | 0 | 00 0000 --- | -6 | 11 1010 --- | 18 | 01 0010 ux | 47 | 10 1111 y | -3 | 11 1101 x >> 1 | -9 | 11 0111 TMax | 31 | 01 1111 -TMin | -32 | 10 0000 TMin+TMin | 0 | 00 0000 ----------------------------------- Problem 2. (u >> 23) & 0xFF u & 0x7FFFFF exp == 0 && frac == 0 exp == 0 exp == 0xFF && frac == 0 exp == 0xFF exp <= 126 sign == 1 Problem 3. for (i = n-1; (i >=0) && (a[i] == val); i = i-1) Problem 4. struct matrix_entry{ short a; or char a; short b; or char b; int c; double d; }; Problem 5. A) Y Y N N N N B) a[0]: 0x38373635, a[1]: 0xE3E20039, buf: 123456789 Problem 6. A) It will return 0 whenever n is odd. B) Change loop test to i > 1 C) Performance is limited by the 4 cycle latency of integer multiplication. D) The multiplication i * (i-1) can overlap with the multiplication by result from the previous iteration. Problem 7. A) 12.5% B) 25% C) 25%