Size of a Word and addressing

前端 未结 2 565
梦毁少年i
梦毁少年i 2021-02-14 08:58

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

相关标签:
2条回答
  • 2021-02-14 09:45

    You are confusing word size and byte size, because word size is determined by the processor and byte size is universal.

    Without using PAE (Physical Address Extension) a 32-bit processor can only handle 4GB of RAM since there are only 2 ^ 32 = 4,294,967,296 different numbers that can be represented using 32 bits. This is a hardware limitation.

    32-bit systems utilizing PAE can address more than 4GB, by mapping processes to page tables. This grants each process access to 4GB of memory. Via supporting PAE, the 32-bit version of Windows Server 2003 Datacenter supports up to 64 GB of RAM on x86-based computers.

    Edit

    Word size denotes the amount of bits a CPU can process at one time. So 32 bits = 4 bytes. However, word size and address size are often used interchangeably which leads to confusion, since they are indeed different. The Pentium Pro was a 32-bit CPU with a 36-bit wide address bus, allowing 64GB of accessible memory (via PAE.)

    0 讨论(0)
  • 2021-02-14 09:55

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

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

    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.

    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.

    You aren't just limited to this on x86:

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

    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/
                ...
    

    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, if your 32-bit CPU uses non-32-bit addresses, the total count will be different.

    0 讨论(0)
提交回复
热议问题