汇编语言间接寻址

发布于 2024-12-13 04:36:10 字数 422 浏览 3 评论 0原文

我正在解决一些间接寻址问题,但我不确定如何正确计算字节。我们得到了这样的代码:

.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

仙气飘飘 2024-12-20 04:36:10

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文