汇编语言间接寻址
我正在解决一些间接寻址问题,但我不确定如何正确计算字节。我们得到了这样的代码:
.data
v1 db 9,7,5,3,1
v2 dw 0
v3 dw -1
v4 db '$'
mov dx,offset v2
mov ah,9
int 21h
问题询问执行这些指令后有多少字节将被写入标准输出设备,答案是 4。
对于这个问题,我这样设置:
offset 0 1 2 3 4 5 6 7 8 9
data 09 07 05 03 01 00 00 FF FF 24
我们将 5 移动到 dx ,写入两个字节 00 05。然后我们设置 dos 代码将其写出,因此我们的输出写出两个字节,即 4 个字节?如果我的逻辑错误,请纠正我。
I am working through some indirect addressing problems and I am not sure how to properly count bytes. We are given this code:
.data
v1 db 9,7,5,3,1
v2 dw 0
v3 dw -1
v4 db '
The question asks how many bytes will have been written to the standard output device after these instructions have been executed and the answer is 4.
For this problem, I set it up like so:
offset 0 1 2 3 4 5 6 7 8 9
data 09 07 05 03 01 00 00 FF FF 24
We are moving 5 into dx, writing two bytes 00 05. We then set the dos code to write it out, so our output writes out the two bytes making four? Please correct me if my logic is wrong.
mov dx,offset v2
mov ah,9
int 21h
The question asks how many bytes will have been written to the standard output device after these instructions have been executed and the answer is 4.
For this problem, I set it up like so:
We are moving 5 into dx, writing two bytes 00 05. We then set the dos code to write it out, so our output writes out the two bytes making four? Please correct me if my logic is wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DOS 函数 9 从 DX 中的偏移量开始写入,直到到达
$
。您已将 V2 的偏移量加载到 DX 中。您已将 V2 和 V3 定义为各两个字节(其中都不包含“$”),后面跟着 V4(包含$
)。因此,它写入V2和V3的四个字节,然后停止。编辑:我应该补充一点,与标题问题相反,您所显示的代码实际上都没有执行任何间接寻址(尽管 DOS 函数 9 无疑确实使用间接寻址,从加载到 <代码>dx)。
DOS function 9 writes starting at the offset in DX until it reaches a
$
. You've loaded the offset of V2 into DX. You've defined V2 and V3 as two bytes apiece (none of which will contain a "$"), and those are followed by V4 (containing the$
). Therefore, it writes the four bytes of V2 and V3, then stops.Edit: I should add that contrary to the title question, none of the code you've shown actually does any indirect addressing (though DOS function 9 undoubtedly does use indirect addressing, reading from the address loaded into
dx
).