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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

吃不起饭的小陈

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值