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

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

问题描述

我正在刷新自己的记忆信息,但对单词的大小感到困惑.根据我的理解,一个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 位 Windows 仅限于 4GB 内存,但阅读单词的含义让我感到疑惑.窗口中的每个字是否等于 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 位德州仪器数字信号处理器就是一个很好的例子.它们的 C/C++ char (AKA byte)、shortint 类型都是一样的大小,16位.这是可以用唯一地址(指针)寻址的最小内存单元,同时也是机器字.由于这些处理器上的数据地址/指针是 16 位的,因此它们最多可以寻址数据存储器中的 216 个 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 位的(如果我们忽略分段和页面转换).这让我们有 232 个唯一的内存地址.而且,很简单,使用它们您可以访问多达 232 8 位字节的内存.但是,您可以使用 232 个唯一地址来寻址多少个 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 上您不仅限于此:

You aren't just limited to this on 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 上用 232 个唯一地址可以寻址多少个 32 位字?如果你说的是所有唯一可寻址和重叠的,那就是其中的 232.OTOH,如果您谈论的是所有唯一可寻址且不重叠的地址,那么就是其中的 230.

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天全站免登陆