Assembly Language for x86 Processors --- 4.3 课后习题答案

4.3 Data-Related Operators and Directives

1 The SIZEOF operator returns the number of bytes in an operand.(SIZEOF运算符返回操作数中的字节数。)

答 :√

2 The OFFSET operator always returns a 16-bit value.(OFFSET运算符始终返回16位值。)

答 :×

3 The PTR operator returns the 32-bit address of a variable.(PTR运算符返回变量的32位地址。)

答 :×

4 The LENGTHOF operator returns the number of bytes in an operand.(LENGTHOF运算符返回操作数中的字节数。)

答 :×

5 The TYPE operator returns a value of 4 for doubleword operands.(TYPE运算符返回双字操作数的值4。)

答 :√

6 Use the following data definitions for the next seven exercises:

.data
myBytes  BYTE 10h,20h,30h,40h    
myWords  WORD 3 DUP(?),2000h        
myString BYTE "ABCDE"

①Insert a LABEL directive in the given data that permits myBytes to be moved directly to a 16-bit register.

答:
myBytes1 LABEL WORD
myBytes BYTE 10h, 20h, 30h, 40h
.code
move ax, myBytes1

②Insert a directive in the given data that aligns myBytes to an even-numbered address.

答 :
.data
ALIGN 2
myBytes BYTE 10h,20h,30h,40h

③Write an instruction that moves all four bytes in myBytes to the EAX register.

答 : mov eax, DWORD PTR myBytes

④Insert a LABEL directive in the given data that permits myWords to be moved directly to a 32-bit register.

答 :
myWordsD LABEL DWORD
myWords WORD 3 DUP(?),2000h
.code
mov eax,myWordsD

⑤Write an instruction that moves the second byte in myWords to the AL register.

答 : mov al, BYTE PTR myWords+1

⑥Write a single instruction that moves the first two bytes in myBytes to the DX register. The resulting value will be 2010h.

答 :mov dx, WORD PTR myBytes

⑦What will be the value of EAX after each of the following instructions execute?

a. mov eax,TYPE myBytes
b.mov eax,LENGTHOF myBytes
c. mov eax,SIZEOF myBytes
d. mov eax,TYPE myWords
e. mov eax,LENGTHOF myWords
f. mov eax,SIZEOF myWords
g. mov eax,SIZEOF myString

答 :
a. 1
b. 4
c. 4
d. 2
e. 4
f. 8
g. 5

猜你喜欢

转载自blog.csdn.net/weixin_43574277/article/details/105575006