Exam 1

Grade Distribution

 Average = 9.5                        X   X X X
 _______________________________X___X_X___X_X_X_X______
   0 . 1 . 2 . 3 . 4 . 5 . 6 . 7 . 8 . 9 . 10. 11. 12
   tentative grade scale        F D D C C B B A A

Solutions

  1. (2 points or 8 minutes) Fill in the following table:
            base2       base8       base10      base16
    
            10110         26          22          16
    
            10011      ___23___    ___19___    ___13___
    
           _11000__       30       ___24___    ___18___
    
           _11110__    ___36___       30       ___1E___
    
           _10111__    ___27___    ___23___       17   
    
  2. (2 points or 8 minutes) Convert the following conventional signed decimal numbers into each of the indicated 6-bit binary signed number systems:
           natural      signed       one's       two's
           decimal    magnituede  complement  complement
    
             -5         100101      111010      111011
    
              5        _000101_    _000101_    _000101_
    
            -20        _110100_    _101011_    _101100_
    
             20        _010100_    _010100_    _010100_
    
            -27        _111011_    _100100_    _100101_
    
    Errors in these first two problems were either careless or indicative of extremely serious problems!

  3. (2 points or 8 minutes) Assemble the following SMAL code:
            . = 0               ||  Address  Value
                W     #1234567  ||
            ; --solved to here--||  000000:  01234567
                B     #89       ||
                H     #ABCD     ||  000004: _??ABCD89_______
                ALIGN 4         ||
                W     "AB"      ||  000008: _00004142_______
                ASCII "AB"      ||
            LAB:                ||  00000C: _????4241_______
                ALIGN 4         ||
                W     LAB       ||  000010: _0000000E_______
                END             ||
                                ||  000014: _????????_______
    
    A common minor problem many students had was to show zeros in the unknown locations instead of question marks. A somewhat more significant problem was the failure of some to understand the difference between the two directives that put "AB" into memory. The most serious problems students had involved failure to understand the effect of the ALIGN directive, failure to give LAB the right value and failure to properly assemble the ASCII values into memory.

  4. (3 points or 12 minutes) Hand assemble the Hawk program fragment shown:
                LIL  R1,#012345 ||  000000:   E101
            ; --solved to here--||  000002:   2345
            LABEL:              ||
                MOVE  R2,R1     ||  000004: __F241__
                ADDSR R1,R0,8   ||
                ADDSI R1,-1     ||  000006: __9108__
                BZR   LABEL     ||
                LEA R2,R2,#DCBB ||  000008: __115F__
                                ||
            Only if you have    ||  00000A: __B2FC__
            time, what values   ||
            are in R1 and R2?   ||  00000C: __F2C2__
                                ||
            R1 = __0___________ ||  00000E: __DCBB__
                                ||
            R2 = __FFFFDDDD____ ||  000010: ________
    
    This problem showed that some students had significant problems with the Hawk instruction format, although many did quite well.

  5. (3 points or 12 minutes) Complete the following SMAL Hawk program.
    	    TITLE	AOTOI ROUTINE
        ;       convert an octal number in an ASCII string
        ;       to a 32 bit unsigned binary integer
        ; -------------------
    	    INT	AOTOI
        AOTOI:  ; function called with return address in R1
        	    ; does not use R2, destroys R4, R5
        	    ; on entry, R3 points to the string holding the number
        	    ; on exit, R3 is the integer value of the string
        	    ; the string terminator is any non octal digit
    	    MOVE    R4,R3
    	    CLR     R3
        AOTOIL:
                LOAD    R5,R4    ; get a character
    	    EXTB    R5,R5,R4 ; extract it
    	    ; convert the ASCII character in R5 to binary
    	    ; and check to see if it is a legal octal digit
    	    ; if not, branch to AOTOIQ
    
    	    CMPI____R5,'7'______________________
    
    	    BGT_____AOTOIQ______________________
    
    	    ADDI____R5,-'0'__;_optimized!_______
    
    	    BLT_____AOTOIQ______________________
    
    	    ; Now, we know R5 is a digit, in binary
    	    ; so compute R3 = R3*8 + R5
    
    	    ADDSL___R3,R5,8__;_optimized!_______
    
    	    ADDSI   R4,1     ; setup to get next byte
    	    BR      AOTOIL   ;   go iterate
        AOTOIQ:
    	    JMPS    R1       ; return
    	    END
    
    A few students arrived at the optimized solution shown above, but most wrote longer solutions separated the range check from the conversion from character to integer, and that separated the shift from the add. There was no penalty for such unoptimality, but penalties were assessed in a few cases where extremely long and un-obvious sequences of instructions were used to do obvious things.

    Many students used hex values instead of ASCII constants. Ther is no justification for this substitution, so it was lightly penalized.