LMU ☀️ CMSI 2210
COMPUTER SYSTEMS ORGANIZATION
Final Exam

Submit all answers on these exam sheets. No extra sheets are allowed.

  1. A 12-bit register can store unsigned values in the range

    ______________________ to ______________________

    and signed values in the range

    ______________________ to ______________________.
  2. 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 
     
       
  3. 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 ______________________________________
  4. 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}$ ______________________________________
  5. Is the 32-bit IEEE value 80833AAA normal or denormal? ___________________
  6. Express the largest normalized IEEE 754 single-precision (32-bit) value in the form $2^x-2^y$ (that is, find $x$ and $y$).
    
    
    ______________________________________
    
  7. 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:


    __________________________________________________
  8. Convert the following codepoints to UTF-8 (Express your answer in hex):
    
    00101101  ____________________________
    
    
    
    000eeeee  ____________________________
    
    
    
    00080000  ____________________________
    
  9. Convert the following codepoints to UTF-16LE (Express your answer in hex):
    
    00101101  ____________________________
    
    
    
    000eeeee  ____________________________
    
    
    
    00008000  ____________________________
    
  10. 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  ____________________________
    
  11. 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

    ______________________________________________

  12. 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
    
  13. Rewrite the formula in the previous problem to use NAND operators only.
    
    
    ______________________________________________
    
  14. 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? ____________________________.
  15. 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)


    ______________________________________________
  16. 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       ___________________________________________
    
  17. Why is it that “strings are hard” in a systems programming language like C?

    _______________________________________________________________________________

    _______________________________________________________________________________
  18. 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?

    _______________________________________________________________________________

    _______________________________________________________________________________

  19. Write a C function that returns the sum of squares of an array of doubles. The array is passed to the function.