CSc 343 Computer Organization and Programming
Fall Quarter 1997
Mid-Term Exam (24 October 1997, Friday) With Solutions

1.  Convert this UNSIGNED BINARY number to DECIMAL: 10011001

    A. 88     B. 102     C. 143     D. 200     E. None of the previous

    ANSWER: E

2.  Convert this SIGNED MAGNITUDE BINARY number to DECIMAL: 10011001

    A. -10     B. -25     C. -50     D. -100     E. None of the previous

    ANSWER: B

3.  Convert this SIGNED ONE'S COMPLEMENT BINARY number to DECIMAL: 10011001

    A. -29     B. -88     C. -102     D. -200     E. None of the previous

    ANSWER: C

4.  Convert this SIGNED TWO'S COMPLEMENT BINARY number to DECIMAL: 10011001

    A. -29     B. -88     C. -102     D. -200     E. None of the previous

    ANSWER: E

5.  What range of DECIMAL NUMBERS fit in a 12 bit UNSIGNED binary field.

    A. 0...2047   B. 0...2048   C. 0...4095   D. 0...4096  E. None of those

    ANSWER: C

6.  What range of DECIMAL NUMBERS fit in a 12 bit binary SIGNED TWO'S
    COMPLEMENT field.

    A. -2047...+2048   B. -2048...+2047   C. -4095...+4096   D.-4096...+4095
    E. None of the above

    ANSWER: B

7.  Convert the number -117.375 to IEEE single-precision floating point format.
    Give your answer in HEX.

    ANSWER: C2EAC000

8.  What does the following IEEE single-precision floating point
    number represent?

    1 11111111 00000000000000000000000

    ANSWER: - infinity

For questions 9-12, perform the specified 8 bit binary operation.
Generate your answers and the values of the Condition Code (SF, ZF, OF,
CF) the way they would be set if these operations were performed by the
Intel 8086.

9. What is the result of performing the following binary operation.

     10111011
   + 10111011
     --------


   A. 10111011    B. 11110110    C. 01110110    D. 01111000    E. None of those

   ANSWER: C

10. Based on the operation performed by the previous question, how will
    the Condition Code bits be set.

   A. SF=0 ZF=0 OF=0 CF=1      B. SF=0 ZF=0 OF=1 CF=1

   C. SF=0 ZF=1 OF=0 CF=1      D. SF=1 ZF=0 OF=1 CF=1    E. None of the above

   ANSWER: B

11. What is the result of performing the following binary operation.

     00010001
   - 01000100
     --------


   A. 10000001    B. 11001111    C. 11000001    D. 11001101    E. None of those

   ANSWER: D


12. Based on the operation performed by the previous question, how will
    the Condition Code bits be set.

    A. SF=1 ZF=0 OF=0 CF=1      B. SF=1 ZF=0 OF=1 CF=1

    C. SF=0 ZF=0 OF=0 CF=1      D. SF=1 ZF=0 OF=1 CF=0    E. None of the above

    ANSWER: E

13. Convert the address EE11:EE22 to a 20-bit address, where EE11 is the 
    contents of the segment register and EE22 is the offset within the 
    segment. Express the answer in HEX notation.

    ANSWER: FCF32

14. Convert the 20-bit address 00100H to segment:offset notation.
    Express the segment and offset as 4-digit HEX numbers.

    ANSWER: 0000:0100

15. What is the SOURCE ADDRESSING MODE for the instruction: ADD AX,[1000]

    A. Register Direct      B. Immediate      C. Memory Direct

    D. Register Indirect    E. It can not be determined

    ANSWER: C

16. What is the DESTINATION ADDRESSING MODE for the instruction: ADD AX,[1000]

    A. Register Direct      B. Immediate      C. Memory Direct

    D. Register Indirect    E. It can not be determined

    ANSWER: A

17. Given these data declaration and instructions and initial hex
    value of AX=1234 then what is in AX after the last instruction
    completes execution.

     LIST     DB     0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15

     MOV  SI,OFFSET LIST
     ADD  SI,5
     MOV  AL,[SI]

  A. 1203      B. 1204     C. 1205      D. 1206    E. None of the above

  ANSWER: C

18. Given these data declaration and instructions and initial hex
    value of AX=1234 then what is in AX after the last instruction
    completes execution.

     LIST     DB     0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15

     MOV  SI,OFFSET LIST
     ADD  SI,10
     MOV  AX,[SI]

  A. 120A      B. 120B     C. 0A0B      D. 0B0A    E. None of the above

  ANSWER: D

19. Given the following data declarations and instructions, how
    many characters will be written to the standard output stream
    (display or file).

     MSG0    DB   `HELLO'
     MSG1    DB   `VAL='
     VALUE   DB   36D 
     FIN     DB   13,10,`$'
     MSG2    DB   `DONE',`$'

     MOV  DX,OFFSET MSG0
     MOV  AH,9
     INT  21H

  A. 0   (decimal)
  B. 9   (decimal)
  C. 11  (decimal)
  D. 12  (decimal)
  E. The number of characters can not be determined

  ANSWER: B

Questions 20-23 refer to the following code:

               MOV  AX,0
               MOV  CX,10
     REPEAT:   INC  AX
               SUB  CX,1
               XXX  REPEAT
     DONE:

20. If the conditional jump (XXX) is replaced by JNE then what
    hex value will be in AX when the loop terminates (we reach the
    instruction DONE:)

    A. 0000    B. 0001      C. 000A     D. 000B     E. None of the above

    ANSWER: C

21. If the conditional jump (XXX) is replaced by LOOP then what
hex value will be in AX when the loop terminates (we reach the
instruction DONE:)

    A. 0004     B. 0005     C. 000A     D. 000B     E. None of the above

    ANSWER: B

22. If the conditional jump (XXX) is replaced by JLE then what hex
    value will be in AX when the loop terminates (we reach the
    instruction DONE:)

    A. 0000     B. 0001     C. 000A     D. 000B     E. None of the above

    ANSWER: B

23. If the conditional jump (XXX) is replaced by JGE then what
    hex value will be in AX when the loop terminates (we reach the
    instruction DONE:)

    A. 0000     B. 0001     C. 000A     D. 000B     E. None of the above

    ANSWER: D

24. How does the instruction ADD AX,100D convert into hex machine code.

    A. 00 01 00
    B. 01 64 00
    C. 03 00 64
    D. 04 01 00
    E. 05 64 00

    ANSWER: E

25. What symbolic instruction is converted into the hex machine code 51

    A. MOV  AL,1
    B. ADD  AX,BX
    C. PUSH CX
    D. CMP  DX,1
    E. INC  BX

    ANSWER: C

26. The following instructions use indirect addressing to point
    to data that is moved to the AX register. Which of these
    instructions refers to data from the Stack Segment that
    is moved to AX.

    A. MOV AX,[SI]
    B. MOV AX,[DI]
    C. MOV AX,[BX]
    D. MOV AX,[BP]
    E. None of the above

    ANSWER: D

27. Write a single instruction that clears (sets to 0) the AX register.
    Do not use the SUB or the MOV instruction.

    XOR AX,AX

28. Name the instruction that could be used to test the bit that was 
    ``shifted off'' during a shift operation.

    JC

29. Suppose that AL contains 93H and BL contains 44H. What is the outcome of 
    the following instructions?

    CMP  AL,BL
    JE   A10       Jumps_______  Does not jump___X___

    CMP  AL,BL
    JNZ   A10      Jumps___X___  Does not jump_______

    CMP  AL,BL
    JAE   A10      Jumps___X___  Does not jump_______

    CMP  AL,BL
    JL   A10       Jumps___X___  Does not jump_______

    CMP  AL,BL
    JB   A10       Jumps_______  Does not jump___X___

30. List the bytes that would be generated by each of the
    following directives. Show byte values in HEX; Write one
    byte per line. (You may not need all the lines provided).
    Show bytes in the order they will appear in memory.



DB  'Foo','bar'   _46_ _6F_ _6F_ _62_ _61_ _72_ ____ ____ ____ ____


DB  -128          _80_ ____ ____ ____ ____ ____ ____ ____ ____ ____


DB  110B,110D     _06_ _6E_ ____ ____ ____ ____ ____ ____ ____ ____


DB  '110'         _31_ _31_ _30_ ____ ____ ____ ____ ____ ____ ____


DW  110           _6E_ _00_ ____ ____ ____ ____ ____ ____ ____ ____


DW  0FFFFH,-1     _FF_ _FF_ _FF_ _FF_ ____ ____ ____ ____ ____ ____


DW  4 DUP (123H)  _23_ _01_ _23_ _01_ _23_ _01_ _23_ _01_ ____ ____

31. The following assembler instructions have been partially
    translated to machine code. Finish the translation by
    filling in the missing words.

    Offset  Machine Code               Source Code
    ______  _____________        __________________________

    0000                             .model small
    0000                             .stack 32
    0000                             .data
    0000                             .code
    0000                        proc1 proc  near
    0000    E8 ____ (ANSWER: 0004)    call  proc2
    0003    05 0001                   add   ax,1
    0006    C3                        ret
    0007                        proc1 endp
    
    0007                        proc2 proc near
    0007    03 C0                     add ax,ax
    0009    C3                        ret
    000A                        proc2 endp
    
    000A                        main  proc far
    000A    B8 0001                   mov  ax,1
    
    000D    E8 ____ (ANSWER: FFF0)    call proc1
    
    0010    E8 ____ (ANSWER: FFF4)    call proc2
    0013    B4 4C                     mov  ah,4cH
    0015    CD 21                     int  21h
    0017                        main  endp
                                      end main 
    
32. Show the top two words on the stack after PROC2 is called from
    PROC1 but before PROC2 has executed the RET instruction. Give
    your answers in HEX words.
    
    Top Word:  _0300__
    
    Next Word: _1000__
    
33. Show the contents (in HEX) of the AX register immediately after 
    the call to PROC2 is completed in the main program. 
    
        AX __0006___





Raj Sunderraman
Tue Oct 28 12:25:52 PST 1997