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 rowmajor 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 Iformat.
This is the end of the preview. Sign up
to
access the rest of the document.
This note was uploaded on 12/12/2010 for the course CSI 333 taught by Professor Ravi during the Fall '08 term at SUNY Albany.
 Fall '08
 RAVI

Click to edit the document details