Exam 1

22C:18, Fall 1996, 12 points

Douglas W. Jones
Name ______________________________________   Section ___________
This exam is open-book and open-notes, but closed neighbor! You have one (academic style) hour, which is defined as 50 minutes. Answer the questions in the space provided. If you need scratch paper, feel free to use the backs of the exam pages, but please transcribe your answers into the blanks provided.
  1. Conversion of unsigned numbers between number bases: In the following table, all numbers in the same column should have the same base, while all numbers in the same row should have the same value, fill in the blanks. The first row is an example. (0.2 points per blank.)
        Base 2           Base 8           Base 10           Base 16
    
     110010101101         6255             3245               CAD
    
        101100           ______           ______            ______
    
       ________            321            ______            ______
    
       ________          ______             321             ______
    
       ________          ______           ______              321
    
    
    

  2. Two's complement numbers: Each column in the following table should contain a decimal value above it's 6-bit two's complement representation. Fill in the blanks. The first column is an example. (0.4 per blank):
        Decimal    -21        25       -6        ______    ______
    
        Binary    101011   ________  ________    011100    111001
    
    
    

  3. Assembly operations: Show the result of assembling the following SMAL code fragment into memory. Show your results as consecutive 32 bit words expressed in hexadecimal, showing unknown values as ? Recall that ASCII 'A' is 41 (hex). (3 points)
                                   Location           Value
        X	=   1
        .   =   #100           _________________ _________________
            B   X
            B   Y              _________________ _________________
        Z:  H   X+Y
            W   Z              _________________ _________________
        Y   =   X+1     
            ASCII 'ABCD'
    
    
    

  4. Hawk instruction format: Show the result of assembling the following Hawk code fragment into memory, assuming the initial value of the location counter is 0. Show your results as consecutive 16 bit halfwords expressed in hex. (2 points)
                                   Location       Value
          LEA   R5,R2,#0123
    loop: LOADS R6,R5              ________ ___________________
          EXTH  R7,R6,R5
          BZS   exit               ________ ___________________
          ADDSI R5,2
          BR    loop               ________ ___________________
    exit: 
                                   ________ ___________________
    
                                   ________ ___________________
    
                                   ________ ___________________
    
                                   ________ ___________________
    
    
    

  5. Hawk Programming: Write a sequence of Hawk assembly instructions to bridge the gap between the following precondition and postcondition. (3 points)
          ; Precondition:  R3 points to a record in memory.
          ; The constant X is the offset of a field in that record.
          ; Field X is an array of 20 words, indexed from 0 up.
          ; R4 holds an integer.
    
          _____________________________________________________
    
          _____________________________________________________
    
          _____________________________________________________
    
          _____________________________________________________
    
          _____________________________________________________
    
          _____________________________________________________
    
          _____________________________________________________
    
          _____________________________________________________
                  
          ; Postcondition:  R5 holds R3->X[R4] (R3^.X[R4] in Pascal).