CSc 343 Computer Organization and Programming Spring Quarter 1998 Solutions to Mid-Term Exam (4 May 1998, Monday) 1. Convert the number -117.375 to IEEE single-precision floating point format. Give your answer in HEX. C2EAC000 2. What does the following IEEE single-precision floating point number represent? FF800000 -infinity 3. Assume that AX = BBBBh and BX = BBBBh. What will be the contents of the AX register after the instruction: ADD AL,BL is executed. A. BBBBh B. BBF6h C. BB76h D. BB78h E. None of these Answer: C What will the condition code bits be after the instruction is executed. 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 4. Assume that AX = 11BBh and BX = 44BBh. What will be the contents of the AX register after the instruction: SUB AH,BH is executed. A. 81BBh B. CFBBh C. C1BBh D. CDBBh E. None of those Answer: D What will the condition code bits be after the instruction is executed. 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 5. 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. FCF32 6. Convert the 20-bit address 00100H to segment:offset notation. Express the segment and offset as 4-digit HEX numbers. 0001:0010 7. 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 8. 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 9. 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 DW 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 MOV SI,OFFSET LIST ADD SI,6 MOV AL,[SI] A. 1203 B. 1204 C. 1205 D. 1200 E. None of the above Answer: A 10. 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 DW 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. 1205 B. 0005 C. 0500 D. 0050 E. None of the above Answer: B 11. 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 12-15 refer to the following code: MOV AX,0 MOV CX,10 REPEAT: INC AX SUB CX,1 XXX REPEAT DONE: 12. 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 13. 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 14. 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 15. 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 16. 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 17. Write a single instruction that clears (sets to 0) the AX register. Do not use the SUB or the MOV instruction. XOR AX,AX 18. Name the instruction that could be used to test the bit that was ``shifted off'' during a shift operation. JC 19. 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____ 20. 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_ ____ ____ ____ ____ ____ ____ ____ ____ ____ DW 0FFFFH,-1 _FF_ _FF_ _FF_ _FF_ ____ ____ ____ ____ ____ ____ DW 4 DUP (1023) _FF_ _03_ _FF_ _03_ _FF_ _03_ _FF_ _03_ ____ ____ 21. Write a short program segment that multiplies AL by 12 using shift, move, and add instructions. mov bl,al mov cl,3 shl al,cl mov cl,2 shl bl,cl add al,bl 22. What will be the contents of AX register after the following instructions execute? MOV AX,63h MOV BL,10h DIV BL AX = 0306 23. 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 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 FFF0 call proc1 ---- 0010 E8 FFF4 call proc2 ---- 0013 B4 4C mov ah,4cH 0015 CD 21 int 21h 0017 main endp end main 24. What will be the contents of AL after each of the following instructions is executed? Assume that AL = EAh, CL = 2, and the Carry Flag is 0 before each instruction is executed. SHL AL,1 AL = D4 SHL AL,CL AL = A8 ROL AL,CL AL = AB RCR AL,CL AL = 3A SAR AL,1 AL = F5 25. Write a procedure that will exchange the high and low halves of the DL register. Make sure that you push and pop any other registers you will use in the procedure. Also, DH should remain unaltered after the procedure is completed. (Hint: Use the logical operations AND/OR with a mask) exchangedl proc near ror dl ror dl ror dl ror dl exchangedl endp