汇编语言字节计数

发布于 2024-12-21 09:04:06 字数 606 浏览 2 评论 0原文

我对变量如何存储在数据段中有点困惑。我们得到了这段代码:

      .data
vala  dw  1234h
valb  db  1,2,3,4
valc  db  '1234$'
vald  db  '12'

我制作了一个偏移数据表,如下所示:

offset  00  01  02  03  04  05  06  07  08  09  10  11
data    34  12  01  02  03  04  31  32  33  34  31  32

我认为我没有正确地将其加载到内存中,因为内存中所需的总字节数是 13,而我这里只有 11。有人可以评论我哪里出错了吗?

还有另一个问题,询问在这些指令之后有多少字节写入标准输出设备:

mov  dx,offset valb    ;valb has 4 bytes
mov  ah,9              ;4 bytes is written to the output
int  21h               ;for a total of 8 bytes

我是否以正确的方式思考这段代码?

I am a bit confused with how variables are stored in the data segment. We are given this segment of code:

      .data
vala  dw  1234h
valb  db  1,2,3,4
valc  db  '1234

I made an offset data table like so:

offset  00  01  02  03  04  05  06  07  08  09  10  11
data    34  12  01  02  03  04  31  32  33  34  31  32

I don't think I am loading it into memory correctly because the total number of bytes required in memory is 13 and I only have 11 here. Can someone comment on where I went wrong?

There is another question that asks how many bytes are written to the standard output device after these instructions:

mov  dx,offset valb    ;valb has 4 bytes
mov  ah,9              ;4 bytes is written to the output
int  21h               ;for a total of 8 bytes

Am I thinking through this segment of code the right way?

vald db '12'

I made an offset data table like so:

I don't think I am loading it into memory correctly because the total number of bytes required in memory is 13 and I only have 11 here. Can someone comment on where I went wrong?

There is another question that asks how many bytes are written to the standard output device after these instructions:

Am I thinking through this segment of code the right way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

白日梦 2024-12-28 09:04:06

你列出了 12 个,而不是 11 个。数一下即可。美元字符缺少一个字节。除此之外,偏移看起来不错。

另外,函数 9 只打印文本,而不打印二进制数。它不会以人类可读的方式打印 valb 中的 4 个字节(1、2、3 和 4)。它会打印多少字节......好吧,它不会打印美元,因为它被用作字符串终止符(请参阅文档,顺便说一句,它都在那里)。因此,它应该只是 8 个(字节 1 到 4 的 4 个奇怪字符以及字符“1”、“2”、“3”和“4”)。

You listed 12, not 11. Just count them. There's one byte missing for the dollar character. Other than that the offsets seem fine.

Also, function 9 only prints text, not binary numbers. It won't print the 4 bytes (1, 2, 3 and 4) from valb in a human-readable way. How many bytes exactly it'll print... well, it won't print the dollar because it's used as the string terminator (see the documentation, btw, it's all there). So, it should be just 8 (4 weird characters for bytes 1 through 4 and characters "1", "2", "3" and "4").

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