简体   繁体   English

内存x86中变量的大小

[英]Size of Variables in Memory x86

I am a bit confused about how variables are stored in memory in x86. 我对如何将变量存储在x86的内存中感到有些困惑。 My professor asked us the following question: 我的教授向我们提出了以下问题:

"Show the memory values from adresses 00 to 0F given the following data segment declarations. You may assume the numbers start at address 00." “给定以下数据段声明,显示从地址00到0F的内存值。您可以假定数字从地址00开始。”

numbers DB 2, 3, 20
sentence DB 'ABCF'
middle DW 45AAH
last DW 72, 1, 2, 3

How I understand it, "numbers" will take up 1 data byte for each element, "sentence" will take up 4 data bytes, one for each letter, "middle" will take up 4 data bytes, 00, 04, 5A and AH, and "last" will take up 8 data bytes, 2 per word. 我的理解是,“数字”将占用每个元素1个数据字节,“句子”将占用4个数据字节,每个字母一个,“中间”将占用4个数据字节,00、04、5A和AH ,“ last”将占用8个数据字节,每个字2个。 However, it appears as if I am only supposed to use 16 bytes worth of memory, from 00 to 0F. 但是,似乎我只应该使用16字节的内存,从00到0F。 How is it possible to fit what appears to be 19 bytes worth of data into those slots? 怎样才能将那些似乎包含19个字节的数据放入这些插槽中?

DW defines a word (16 bits). DW定义一个字(16位)。 Hence middle takes two bytes: 0xAA and 0x45. 因此, 中部占用两个字节:0xAA和0x45。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM