final exam

# final exam - CSI 333 Solutions to the Sample Final Exam...

This preview shows pages 1–3. Sign up to view the full content.

Sheet1 Page 1 CSI 333 -- Solutions to the Sample Final Exam --------------------------------------------- Question I: ----------- (a) The device stdout is buffered while stderr is not buffered. (b) No, it won't read a value into y[4]. The reason is that *(y+4) is not an address. (Recall that scanf needs an address.) (c) No, it won't initialize the array to the given string. The reason is that the name of an array represents the starting address of the array which cannot be changed by any statement. (d) The "lbu" opcode sets the most significant 24 bits to 0 while the "lb" opcode propagates the sign bit of the byte into the most significant 24 bits. (e) The code does not push the value correctly. Since the stack should grow towards lower addresses, a correct push operation should subtract 4 from the stack pointer's value. Err:510 Question II: ------------ (a) 27 (base 9) = 2 x 9 + 7 = 25 decimal. We convert 25 (decimal) into its base 3 representation as follows. Division Quotient Remainder 25/3 8 1 8/3 2 2 2/3 0 2 Therefore, 27 (base 9) = 221 (base 3). (b) 42.4 (base 5) = 4 x 5 + 2 + 4 x (1/5) = 22.8 decimal. Now 22 (decimal) = 16 (hex) = 10000 binary. To convert 0.8 (decimal) into binary, we have: 0.8 x 2 = 1.6 bit = 1 0.6 x 2 = 1.2 bit = 1 0.2 x 2 = 0.4 bit = 0 0.4 x 2 = 0.8 bit = 0 Now, the bit pattern 1100 repeats indefinitely. Therefore,

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Sheet1 Page 2 ---- 42.4 (base 5) = 10000.1100 (binary) (c) Plugging into the formula for computing addresses in row-major order, we have Address of A[2][4] = 700 + 4 x 2 x 6 + 4 x 4 = 764 (decimal). (d) The lw instruction uses the I-format.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 12

final exam - CSI 333 Solutions to the Sample Final Exam...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online