The test is open-everything with the sole limitation that you
neither solicit nor give help while the exam is in progress.
Submit all answers on these exam sheets. No extra sheets are allowed.
- A 12-bit register can store unsigned values in the range
______________________ to ______________________
and signed values in the range
______________________ to ______________________.
- Complete the following table. All word sizes here are 16-bits.
| Modular Sum
| Signed Saturated Sum
| Carry (y/n)
| Overflow (y/n)
|
7214 + 0326 | | | |
|
3517 + 4BFC | | | |
|
6519 + F700 | | | |
|
B0BA + 1ACF | | | |
|
8508 + 92E7 | | | |
|
FFFF + FFFF | | | |
|
- Express exactly (and I do mean exactly):
$2^{50}$ bytes in TiB ______________________________________
4096 pebibytes in EiB ______________________________________
1000 bytes in KiB ______________________________________
$2^{33}+2^{29}$ bytes in GiB ______________________________________
- Give the single precision IEEE-754 encoding of each of the following:
$-3\frac{27}{64} \times 2^{-120}$ ______________________________________
$-9\frac{5}{8} \times 2^{-140}$ ______________________________________
$16\frac{11}{16} \times 2^{100}$ ______________________________________
- Is the 32-bit IEEE value 80833AAA normal or denormal? ___________________
- Express the largest normalized IEEE 754 single-precision (32-bit) value in the form $2^x-2^y$ (that is, find $x$ and $y$).
______________________________________
- For each of the following, give the corresponding sequence of characters (in “U+” format).
Medium skin tone woman surfer:
__________________________________________________
Medium skin tone man singer:
__________________________________________________
Flag of American Samoa:
__________________________________________________
- Convert the following codepoints to UTF-8 (Express your answer in hex):
00101101 ____________________________
000eeeee ____________________________
00080000 ____________________________
- Convert the following codepoints to UTF-16LE (Express your answer in hex):
00101101 ____________________________
000eeeee ____________________________
00008000 ____________________________
- Decode each of the following UTF-8 byte sequences into the corresponding character sequences. If a byte sequence is found to be malformed, or decodes into non-characters, decode as much of it as you can (that is, up until the error) and then state what is wrong with the sequence.
33 C2 A9 E3 80 ____________________________
E9 A3 90 F9 80 80 B1 20 ____________________________
D9 B1 F0 80 92 C5 ____________________________
- Given a 32-bit word that is assumed to contain an unsigned integer, give a logic operation that will perform each of the following tasks:
Complement the middle four bits _____________________________________
Replace it with its value mod 512 ________________________________________
Replace it with the largest multiple of 128 less than or equal to itself
______________________________________________
- Give a truth table for $A(\overline{B \oplus C})$
A B C
----------------------
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
- Rewrite the formula in the previous problem to use NAND operators only.
______________________________________________
- Suppose that address 7 in the simple computer’s memory was found to contain the word 30000A003. How is this interpreted as an instruction? ____________________________ How is it interpreted as data? ____________________________.
- What does the instruction sequence
STORE 50 / XOR 50
do to the accumulator? (Don’t just say “stores it in address 50 then xors it with the contents of address 50”; talk of its effect at a high level)
______________________________________________
- What does the following code sequence do? (Again, answer at a high-level):
LOAD Y Answer: ___________________________________
SUB X
JGZ L1 ___________________________________________
LOAD Y
JUMP L2 ___________________________________________
L1: LOAD X
L2: OUT 30 ___________________________________________
- Why is it that “strings are hard” in a systems programming language like C?
_______________________________________________________________________________
_______________________________________________________________________________
- Here is a C function that makes a copy of string:
char* duplicate(char* s) {
int len = strlen(s);
char* t = malloc(len + 1);
for (int i = 0; i <= len; i++) {t[i] = s[i];}
return t;
}
This works (assuming you included all the right things). Suppose you changed the line declaring t
to be char t[len+1];
. Why is that horrifying and wrong?
_______________________________________________________________________________
_______________________________________________________________________________
- Write a C function that returns the sum of squares of an array of
doubles. The array is passed to the function.