Next: About this document

NAME:SECTION:
CS 2011
Exam 1
C-Term 1995

  1. (16 points)A byte of memory contains the hexadecimal value E6. What decimal number does this represent, if the byte is interpreted as containing:
    1. an 8-bit unsigned integer

    2. an 8-bit signed integer in sign-magnitude form

    3. an 8-bit signed integer in one's complement form

    4. an 8-bit signed integer in two's complement form

  2. (8 points) Assume that the hex value 42018000 represents a floating point number in IEEE-standard single precision format. What decimal number does it represent? Show your work.

  3. (12 points) Given the following register values in hex:
    
          DS  9312     SP  0012     AX  0001     SI  FFFF
          SS  6676     BP  00F3     BX  0002     DI  ABCD
          CS  4ABC     IP  112A     CX  0003
          ES  9312                  DX  0004
    1. Calculate the effective address from which the next byte of machine code will be fetched. Give your answer as a 5-digit hexadecimal number.

    2. What is the segment address for the stack segment? Give your answer as a 5-digit hexadecimal number.

    3. Which two values could be used as offsets into the stack segment?

  4. (5 points each) Write an assembly language instruction or set of instructions to perform the following:
    1. Put the value 12 (decimal) in the high-order byte of the AX register.

    2. Compare the signed values in AX and BX and jump to LESS if BX is less than AX.

    3. Subtract the value in AX from the value in BX.

    4. Move into the AX register the contents of the word whose address is contained in the BX register.
  5. (16 points) Write assembly language code to implement the following IF-THEN-ELSE statement. Assume you are dealing with unsigned numbers.
    
      IF  ( ((AX) < 10) AND ((BX) < 10) ) THEN
          assign 1 to the CX register
      ELSE
          assign 0 to the CX register
      ENDIF

  6. (10 points) An assembly language program contains this data declaration:
    
           .data
    Array1  DB   1, 2, 3
    Array2  DW   -1, -2, -3
    Assume these values get loaded into memory beginning at location 1124C. Show the contents of memory at each of the following byte addresses (give your answers in hex). You may put ? as the contents of a memory location if it is not defined by the .data area given.
    
           address          contents
           -------          --------
    
            1124C
    
            1124D
     
            1124E
    
            1124F
    
            11250
    
            11251
    
            11252
    
            11253
    
            11254
    
            11255
    
            11256
    
            11257
  7. (10 points) Given below is a portion of an assembly language program. What does it do? (Don't give a line-by-line description; give me a general description).
    
           .data
    strng  db ``Happy Valentines Day''
    N = $ - strng
    
           .code
             .
             .
             . 
           LEA    BX, strng
           MOV    SI, BX
           MOV    CX, N
    
    A1:    MOV    AL, BYTE PTR [BX]
           CMP    AL, 'a'
           JE     A2
           MOV    [SI], AL
           INC    SI
    A2:    INC    BX
           LOOP   A1
             .
             .
             .

  8. (8 points) Show the settings in the flags register after the execution of the following pair of instructions.
    
           MOV  BL, 0FAH                    CF=       ZF=
           ADD  BL, 0AH                     SF=       OF=




Next: About this document


ghamel@cs.WPI.EDU
Thu Jan 25 12:15:15 EST 1996