CSCI 162 practice midterm [48 marks total]

The midterm is closed book, closed notes, no calculators or other electronics permitted. A reference sheet is included with the midterm, covering key Marie opcodes and boolean logic identities.


Part 1: data representation [16 marks]

  1. If we are representing unsigned integers in hexadecimal, what is the result of E9A + 375?
    What is the equivalent value in decimal?

  2. If we are representing signed integers in 8-bit binary using ones complement, what is the result of 00001101 + 11110011?
    What is the equivalent value in decimal?

  3. If we are representing signed integers in 8-bit binary using twos complement, what is the result of 00010101 + 11101010?
    What is the equivalent value in decimal?

  4. If we want to multiply a binary number by 16, how can we achieve this using shift operations?

  5. In terms of binary representations of numbers, why does the following C code produce an infinite loop?
       float x = 0.1;
       float sum = 0;
       while (sum != 1) {
          sum = sum + x;
       }
       


Part 2: digital logic [16 marks]

  1. Complete the truth table and Karnaugh map below for the function f = xy' + wxy + y'z'
    w x y zxy'wxyy'z'f(wxyz)
    0 0 0 0    
    0 0 0 1    
    0 0 1 0    
    0 0 1 1    
    0 1 0 0    
    0 1 0 1    
    0 1 1 0    
    0 1 1 1    
    1 0 0 0    
    1 0 0 1    
    1 0 1 0    
    1 0 1 1    
    1 1 0 0    
    1 1 0 1    
    1 1 1 0    
    1 1 1 1    
      yz
    wx 00 01 11 10
    00        
    01        
    11        
    10        

  2. Given the Karnaugh map shown below, provide a minimal sum-of-products expression for the function. (Treat the empty cells as 0's.)
      yz
    wx 00 01 11 10
    00 1     1
    01   1 1  
    11   1 1  
    10   1    

  3. Sketch the logic circuit corresponding to the 3-input, 2-output function below, using 2 NOT gates, 2 OR gates, one NOR gate, and 3 AND gates.
    f = (x + y')(xy + z)'
    g = xy + y'z'


Part 3: architecture and assembly language [16 marks]

  1. Architecture and the fetch-decode-execute cycle (8 marks)
    Given the Marie code and program state shown below, briefly illustrate the fetch-decode-execute cycle using the next three instructions to run as an example, showing the output and the changing values of the acc, pc, and ir registers.
    (See the reference sheet for the machine code corresponding to each type of instruction.)

            org         100
            input
    Top,    skipcond    800
            jump        Done
            output
            subt        decr
            jump        Top
    Done,   halt
    decr,   dec         1
    
    ACC: 0003
    
    IR:  6000
    
    PC:   104
    
    

  2. Write a Marie program (8 marks) that reads two integer values, x and y, then keeps doubling the value of x until the result is larger than y. It then outputs the value of x.