汇编语言字节计数
我对变量如何存储在数据段中有点困惑。我们得到了这段代码:
.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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你列出了 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").