Exam 1

22C:18, Spring 1996, 12 points

Douglas W. Jones
Name ______________________________________   Section ___________
  1. Conversion of unsigned numbers between number bases: In the following table, all numbers in the same column have the same base, while all numbers in each row have the same value, fill in the blanks. (0.2 points per blank.)
        Base 2           Base 8           Base 10           Base 16
    
       11101011           353               235               DB
    
        101010           _____             _____             _____
    
        ______            127              _____             _____
    
        ______           _____              127              _____
    
        ______           _____             _____              127
    

  2. Two's complement numbers: The following table contains conventional signed decimal numbers and their 6-bit 2's complement binary representations. (0.4 per blank):
        Decimal    -25        20       -12       ______    ______
    
        Binary    100111   ________  ________    010110    110010
    

  3. Assembly pseudo operations: Show the result of assembling the following M68000 code fragment into memory, assuming that the initial value of the location counter is 00100000 (hexadecimal). Show your results as consecutive 32 bit longwords expressed in hexadecimal, showing unknown values as ? (3 points)
                                   Location           Value
        A:  EQU  $1
                               _________________ _________________
        ;   comment
            DC.L A             _________________ _________________
            DC.L B
            DC.L C             _________________ _________________
            DC.B 'ABC',0
        B:  DS.B 3             _________________ _________________
        C:  DS.B A
                               _________________ _________________
    
                               _________________ _________________
    
                               _________________ _________________
    
                               _________________ _________________
    
                               _________________ _________________
    

  4. M68000 instruction format: Show the result of assembling the following M68000 code fragment into memory, assuming the initial value of the location counter is 0. Show your results as consecutive 16 bit words expressed in binary. (2 points)
                                   Location       Value
         MOVE.L  (SP),$1234(A3)
         ADDQ.W  #7,SP             ________ ___________________
         CMPA.W  -(A3),A0
                                   ________ ___________________
    
                                   ________ ___________________
    
                                   ________ ___________________
    
                                   ________ ___________________
    

  5. M68000 Programming: Write a sequence of M68000 assembly instructions to bridge the gap between the following precondition and postcondition. (3 points)
          ; Precondition:  A0 points to a record in memory.
          ; X and Y are symbolic names for fields in the record.
          ; Field X is a word; field Y is an array of 20
          ; long words (array indices go from 0 to 19).
    
          _____________________________________________________
    
          _____________________________________________________
    
          _____________________________________________________
    
          _____________________________________________________
    
          _____________________________________________________
    
          _____________________________________________________
    
          _____________________________________________________
    
          _____________________________________________________
                  
          ; Postcondition:  D0 holds A0^.Y[X] (or A0->Y[X] in C)