字的大小和地址 [英] Size of a Word and addressing

查看:83
本文介绍了字的大小和地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在刷新自己的内存信息,但对Word的大小感到困惑.根据我的理解,Word不是通用定义的大小,而是特定系统定义的大小(以字节数表示).

I was refreshing myself on memory information and I am confused on the size of a Word. From my understanding, a Word is not a universally defined size, but is a size defined by the specific system (in terms of number of bytes).

根据维基百科:

因此,具有32位内存地址的处理器可以直接访问4 GiB的字节可寻址内存.

Hence, a processor with 32-bit memory addresses can directly access 4 GiB of byte-addressable memory.

这是否意味着32位处理器可以处理4,294,967,295个?32位窗口仅限于4GB RAM,但是我想知道一个单词的含义.Windows中的每个Word是否等于1个字节?一个单词的大小可以只是一个更大的字节数,而一个32位处理器能够寻址8GB,10GB,12GB甚至更多的内存吗?

Does that mean that a 32-bit processor can address 4,294,967,295 Words? 32-bit windows is limited to 4GB of RAM, but reading over the meaning of a word had me wondering. Does each Word in windows equate to 1 byte? Could the size of a word just be a larger number of bytes and a 32-bit processor be able to address 8GB, 10GB, 12GB or even more memory?

推荐答案

这是否意味着32位处理器可以处理4,294,967,295个字?

Does that mean that a 32-bit processor can address 4,294,967,295 Words?

这取决于CPU及其外观.

It depends on the CPU and on how you look at it.

有些CPU不能处理小于一个字的内容.16位德州仪器(TI)数字信号处理器就是一个很好的例子.它们的C/C ++ char (又名 byte ), short int 类型的大小相同,均为16位.这是可以用唯一地址(指针)寻址的最小内存单元,并且这是同时的机器字.由于这些处理器上的数据地址/指针是16位的,因此它们最多可以寻址数据存储器中的2 16 16位字.

There are CPUs that can't address anything smaller than a word. 16-bit Texas Instruments Digital Signal Processors are a good example. Their C/C++ char (AKA byte), short and int types are all of the same size, 16 bits. And that is the smallest unit of memory that can be addressed with a unique address (pointer) and that's the machine word at the same time. Since data addresses/pointers are 16-bit on these processors, they can address at most 216 16-bit words in the data memory.

现在,如果您以32位操作模式返回到x86 CPU,情况将有所不同.存储器的最小可寻址单元是8位字节,最大的是32位字(机器字).地址和指针也是32位的(如果我们忽略分段和页面转换).这使我们拥有2 32 个唯一的内存地址.而且,通过它们,您最多可以访问2 32 8位字节的内存.但是,您可以用2 32 个唯一地址寻址多少个32位字?答案取决于您是否要使用不重叠或重叠的单词.您会看到,x86 CPU可以在任何地址访问32位内存单元,而不仅是4字节倍数的地址.

Now, if you go back to x86 CPUs in 32-bit modes of operation, things are a little different. The smallest addressable unit of memory is an 8-bit byte and the largest is a 32-bit word (machine word). Addresses and pointers are 32-bit as well (if we ignore segmentation and page translation). This lets us have 232 unique memory addresses. And, trivially, with them you can access up to 232 8-bit bytes of memory. But how many 32-bit words can you address with 232 unique addresses? The answer depends on whether you want non-overlapping or overlapping words. You see, the x86 CPU can access 32-bit units of memory at any address, not just at addresses that are multiple of 4 bytes.

您不仅限于x86:

  0 1 2 3 4 5 6 7  <- address
  \word/  \word/

这些都是在x86上用于32位字访问的所有有效地址:

These all are all valid addresses for 32-bit word accesses on x86:

  0 1 2 3 4 5 6 7  <- address
  \word/  | | | |
    \word/  / | |
      \word/  / |
        \word/  /
          \word/
            ...

那么,在x86上用2 32 个唯一地址可以寻址多少个32位字?如果您谈论的是所有唯一可寻址和重叠的地址,那么它们就是2 32 .如果是OTOH,那么您谈论的是所有唯一可寻址且不重叠的变量,那就是其中的2 30 .

So, how many 32-bit words can you address with 232 unique addresses on x86? If you're talking about all uniquely addressable and overlapping ones, that's 232 of them. If, OTOH, you're talking about all uniquely addressable and non-overlapping ones, that's 230 of them.

OTOH,如果您的32位CPU使用非32位地址,则总数将有所不同.

OTOH, if your 32-bit CPU uses non-32-bit addresses, the total count will be different.

这篇关于字的大小和地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆