Excercise - Chapter04

2020-03-27 19:19

Chapter 4 Test Bank

Fill in the Blanks and Short Answer

Use the following data definitions until notified otherwise:

byte1 BYTE 0FFh,1,2 byte2 BYTE 14h

word1 WORD 0FFFFh,1,2 word2 WORD 3

word3 SWORD 7FFFh,8000h word4 SWORD 9000h

dword1 DWORD 10h,20h,30h,40h dArray DWORD 10 DUP(?)

1. Write one or more statements that move the contents of word1 to word2.

2. For each of the following instructions, indicate whether it is legal (L) or illegal (I):

a. mov byte2,0FFh b. mov word1,byte2 c. mov word2,10000h d. mov si,word1

3. For each of the following instructions, indicate whether it is legal (L) or illegal (I):

a. movzx ax,byte1 b. movzx edx,bl c. movzx word2,al d. movsx dl,al

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

b. c. d.

a.

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] mov al,[byte1+1] mov eax,[word3+4]

a. mov eax,[dword1+4] c. d.

b.

6. Where marked by a letter (a, b, c, d), indicate the hexadecimal value of the destination operand:

mov ax,word1

inc ax dec ax mov ax,word3 neg ax add 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 al,7Fh add al,2 sub al,5 mov al,80h add al,80h neg al

a: ZF,CF,SF,OF= b: ZF,CF,SF,OF=

c: ZF,CF,SF,OF= d: ZF,CF,SF,OF=

8. Which instruction loads the low byte of the EFLAGS register into AH?

Irvine, Kip R. Assembly Language for Intel-Based Computers, 4th Edition

1

9. 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 EBX to location word1: 12. What is the value of the expression (TYPE word1)? 13. What is the value of the expression (TYPE dword1)?

14. What is the value of the expression (LENGTHOF word1)? 15. What is the value of the expression (SIZEOF word1)? Short Programming Problems

Use the following data definitions until notified otherwise:

byte1 BYTE 0FFh,1,2 byte2 BYTE 14h

word1 WORD 0FFFFh,1,2 word2 WORD 3

word3 SWORD 7FFFh,8000h word4 SWORD 9000h

dword1 DWORD 10h,20h,30h,40h dArray DWORD 10 DUP(?)

16. Implement the following expression in assembly language, using 32-bit integers (you may modify any r

eax = dword1 + ebx - ecx

17. Implement the following expression in assembly language, using 32-bit integers (you may modify any

registers you wish):

eax = -dword1 + (edx - ecx) + 1

18. using 32-bit integers. The notation dword[1] corresponds to an array reference in C++ or Java:

dArray[0] = dArray[1] + dArray[2]

19. Use the following data declarations to write an assembly language loop that copies the string from source to

target. Use indexed addresing with EDI, and use the LOOP instruction.

source BYTE \target BYTE SIZEOF source DUP(0),0

Multiple-Choice

20. The MOV instruction does not permit an immediate value to be moved to a segment register.

a. true b. false

21. The DS register can be the destination operand of a MOV instruction.

a. true b. false

22. The ES register can the source operand of a MOV instruction.

a. true b. false

23. The SAHF instruction copies the EFLAGS register into a 32-bit memory location.

a. true

Irvine, Kip R. Assembly Language for Intel-Based Computers, 4th Edition

2

b. false

24. The INC instruction does not affect the Carry flag.

a. true b. false

25. Adding 7Fh and 05h in an 8-bit register sets the Overflow flag.

a. true b. false

26. Adding 0FFh and 05h in an 8-bit register sets the Overflow flag.

a. true b. false

27. Adding 5 to 0FBh in an 8-bit register sets the Zero flag.

a. true b. false

28. The following instructions will set the Sign flag:

mov al,0FEh sub al,2

a. true b. false

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 byte2 BYTE 14h

word1 WORD 0FFFFh,1,2 word2 WORD 3

word3 SWORD 7FFFh,8000h word4 SWORD 9000h

dword1 DWORD 10h,20h,30h,40h dArray DWORD 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

Irvine, Kip R. Assembly Language for Intel-Based Computers, 4th Edition

3

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 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

Irvine, Kip R. Assembly Language for Intel-Based Computers, 4th Edition

4

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: mov [esi-4],eax a. 0, 0, 0 b. 0, 1, 2 c. 1, 2, 3 d. 0, 0, 1

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:

mov edi,OFFSET dword1

Irvine, Kip R. Assembly Language for Intel-Based Computers, 4th Edition

5

2: mov ecx,LENGTHOF dword1 3: ? 4: ? 5: ?

6: loop L1

Which of the following choices would best fill in lines 3, 4, and 5? a.

3: mov eax,[edi] 4: L1: add eax,dword1 5: add edi,2

b.

3: mov eax,0

4: L1: add eax,[edi] 5: add edi,TYPE dword1 c.

3: mov eax,0

4: L1: add eax,[edi] 5: add edi,2 d.

3: mov DWORD PTR [edi],0 4: L1: add eax,[edi] 5:

add edi,TYPE dword1

Irvine, Kip R. Assembly Language for Intel-Based Computers, 4th Edition

6


Excercise - Chapter04.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2011.5 大班音乐欣赏:动物狂欢节

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: