ch04
7 Pages

ch04

Course Number: CS 561, 2009

College/University: Emporia

Word Count: 1190

Rating:

Document Preview

Chapter 4 Fill in the Blanks and Short Answer Use the following data definitions until notified otherwise: byte1 byte2 word1 word2 word3 word4 dword1 dArray 1. 2. BYTE BYTE WORD WORD SWORD SWORD DWORD DWORD 0FFh,1,2 14h 0FFFFh,1,2 3 7FFFh,8000h 9000h 10h,20h,30h,40h 10 DUP(?) Write one or more statements that move the contents of word1 to word2. For each of the following instructions, indicate whether it is...

Unformatted Document Excerpt
Coursehero >> Kansas >> Emporia >> CS 561

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

4 Fill Chapter in the Blanks and Short Answer Use the following data definitions until notified otherwise: byte1 byte2 word1 word2 word3 word4 dword1 dArray 1. 2. BYTE BYTE WORD WORD SWORD SWORD DWORD DWORD 0FFh,1,2 14h 0FFFFh,1,2 3 7FFFh,8000h 9000h 10h,20h,30h,40h 10 DUP(?) Write one or more statements that move the contents of word1 to word2. For each of the following instructions, indicate whether it is legal (L) or illegal (I): a. b. c. d. mov mov mov mov byte2,0FFh word1,byte2 word2,10000h si,word1 ax,byte1 edx,bl word2,al dl,al 3. For each of the following instructions, indicate whether it is legal (L) or illegal (I): a. b. c. d. movzx movzx movzx movsx 4. Indicate the hexadecimal value of the destination operand next to each instruction. Use the letter I to indicate that a particular instruction is illegal: mov dx,word3 movsx eax,byte1 mov dh,al mov bx,dx a. b. c. d. 5. Indicate the hexadecimal value of the destination operand next to each instruction. Use the letter I to indicate that a particular instruction is illegal: mov ax,[word3+2] b. mov al,[byte1+1] mov eax,[word3+4] a. mov eax,[dword1+4] c. d. 6. Where marked by a letter (a, b, c, d), indicate the hexadecimal value of the destination operand: mov inc dec mov neg add ax,word1 ax ax ax,word3 ax ax,0C2A5h a. b. c. d. 7. Where marked by a letter (a, b, c, d), indicate the hexadecimal value of the destination operand: mov add sub mov al,7Fh al,2 al,5 al,80h a: ZF,CF,SF,OF= b: ZF,CF,SF,OF= 1 Chapter 4 add al,80h neg al 8. 9. c: ZF,CF,SF,OF= d: ZF,CF,SF,OF= Which instruction loads the low byte of the EFLAGS register into AH? Write an instruction that moves the 32-bit address of word1 into the ESI register (assume 32-bit Protected mode). 10. Write an instruction that moves the lower 16 bits of dword1 into the BX register (hint: use PTR). 11. Write an instruction that moves the lower 8 bits of word2 into the AL register. 12. Write an instruction that moves EBX to location word1: 13. What is the value of the expression (TYPE word1)? 14. What is the value of the expression (TYPE dword1)? 15. What is the value of the expression (LENGTHOF word1)? 16. What is the value of the expression (SIZEOF word1)? Multiple-Choice 17. The MOV instruction does not permit an immediate value to be moved to a segment register. a. true b. false 18. The MOVSX instruction sign-extends an integer into a larger operand. a. true b. false 19. The DS register can be the destination operand of a MOV instruction. a. true b. false 20. The ES register can the source operand of a MOV instruction. a. true b. false 21. The SAHF instruction copies the EFLAGS register into a 32-bit memory location. a. true b. false 22. The INC instruction does not affect the Carry flag. a. true b. false 23. Adding 7Fh and 05h in an 8-bit register sets the Overflow flag. a. true b. false 24. Adding 0FFh and 05h in an 8-bit register sets the Overflow flag. a. true 2 Chapter 4 b. false 25. Adding 5 to 0FBh in an 8-bit register sets the Zero flag. a. true b. false 26. The following instructions will set the Carry flag: mov al,0FEh sub al,2 a. true b. false 27. The following instructions will set the Sign flag: mov al,0FEh sub al,2 a. true b. false 28. Select the answer choice that best implements the following expression. Do not permit dword1, ECX, or EDX to be modified: eax = -dword1 + (edx - ecx) + 1 a. mov neg sub add inc b. mov neg sub mov add inc c. neg mov sub add inc d. mov mov sub add inc eax,dword1 edx,ebx ebx,ecx eax,ebx eax dword1 ebx,edx ebx,ecx eax,ebx eax eax,dword1 eax ebx,edx ebx,ecx eax,ebx eax eax,dword1 eax edx,ecx eax,edx eax Some of the following questions have more than one correct answer. Circle all correct answers: Use the following data definitions until notified otherwise: byte1 BYTE 0FFh,1,2 3 Chapter 4 byte2 word1 word2 word3 word4 dword1 dArray BYTE WORD WORD SWORD SWORD DWORD DWORD 14h 0FFFFh,1,2 3 7FFFh,8000h 9000h 10h,20h,30h,40h 10 DUP(?) 29. What is the hexadecimal value of AX when this code executes? mov esi,OFFSET word1 add esi,4 mov ax,[esi] a. 1 b. 2 c. FFFFh d. 3 30. What is the final hexadecimal value of AX when this code executes? mov ebx,OFFSET dword1 sub ebx,2 mov ax,[ebx] a. 0000h b. 0010h c. 9000h d. 0020h 31. What is the final hexadecimal value of AL when this code executes? mov ebx,OFFSET byte1 mov al,[ebx+3] a. 1 b. 2 c. 14h d. 3 32. What is the final hexadecimal value of EAX when this code executes? mov edx,8 mov eax,dword1[edx] a. 00000010h b. 20000000h c. 00300000h d. 00000030h 33. In Protected mode, which of the following define(s) a pointer variable containing the offset of word1? a. ptr1 DWORD word1 4 Chapter 4 b. word1 DWORD ptr1 c. ptr2 DWORD PTR word1 d. ptr2 DWORD OFFSET word1 34. Suppose the statement PWORD TYPEDEF PTR DWORD has already appeared in a program. Which of the following data declarations would be correct? a. PTR DWORD var1 ? b. var2 PWORD ? c. var3 PTR DWORD ? d. var4 PTR PWORD ? Example 2 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: .data varX DWORD 9,8,7,6,5,4,3,2,1,0 varY DWORD (LENGTHOF varX) DUP(0) .code mov esi,OFFSET varY + (SIZEOF varX) - 4 mov edi,4 mov ecx,LENGTHOF varX - 1 L1: mov eax,varX[edi] mov [esi],eax add edi,4 sub esi,4 loop L1 35. Refer to Example 2. After the loop executes, what will be the values at locations varY, varY+4, and varY+8? a. 0, 0, 0 b. 0, 1, 2 c. 1, 2, 3 d. 0, 0, 1 36. Refer to Example 2. After the loop executes, what will be the values in the last three positions (array elements) of varY? a. 0, 0, 0 b. 8, 9, 0 c. 6, 7, 8 d. 7, 8, 9 37. Refer to Example 2. If line 9 were changed to the following, what would be the final values at locations varY, varY+4, and varY+8? 9: a. 0, 0, 0 b. 0, 1, 2 c. 1, 2, 3 d. 0, 0, 1 mov [esi-4],eax 5 Chapter 4 Use the following data for the remaining questions in this section: word1 WORD 1000h,2000h,3000h,4000h,5000h dword1 DWORD 10000h,20000h,30000h,40000h 38. What is the final value of AX after this code has executed? mov esi,OFFSET word1 mov ecx,5 mov eax,100h L1: add ax,[esi] add ax,16 add esi,TYPE word1 Loop L1 a. F150h b. 0150h c. F016h d. 0016h 39. What is the final value of AX after this code has executed? mov edx,OFFSET word1+8 mov ecx,2 mov ax,0 L1: mov ax,[edx] add ax,20h sub edx,4 Loop L1 a. 8040h b. 9040h c. 4020h d. 3020h 40. Suppose we want EAX to contain the sum of the dword1 array when the following (incomplete) code finishes executing: 1: 2: 3: 4: 5: 6: mov edi,OFFSET dword1 mov ecx,LENGTHOF dword1 ? ? ? loop L1 Which of the following choices would best fill in lines 3, 4, and 5? a. 3: 4: 5: b. 3: 4: mov L1: add eax,0 eax,[edi] mov L1: add add eax,[edi] eax,dword1 edi,2 6 Chapter 4 5: c. 3: 4: 5: d. 3: 4: 5: mov L1: add add DWORD PTR [edi],0 eax,[edi] edi,TYPE dword1 mov L1: add add eax,0 eax,[edi] edi,2 add edi,TYPE dword1 7
MOST POPULAR MATERIALS FROM CS
MOST POPULAR MATERIALS FROM Emporia