Size of a Word and addressing

15,223

Solution 1

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.

Solution 2

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

Share:
15,223
Justin
Author by

Justin

I work with C#, ASP.NET, Telerik products, Typescript, CSS/HTML, SQL, and sensor systems and hardware. When not at work I tinker with 3D printing, Arduinos, and other small electronics. Coding is just pressing buttons on the keyboard. You just have to make sure you do it in the right order.

Updated on June 15, 2022

Comments

  • Justin
    Justin almost 2 years

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

    According to wikipedia:

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

    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?

    • Ken White
      Ken White about 11 years
      Read again what you quoted. It says 4GiB of **byte-addressable** memory, meaning just that: bytes. Not words, or DWORDS, but byte.
    • arkon
      arkon about 11 years
      If I remember correctly, word size is determined by the CPU, and the processor's word size is determined by the width of its external data bus (though it can be narrower.)
    • Justin
      Justin about 11 years
      @KenWhite Hence my confusion. Thats why I am posting. Why is it bytes and not words. I guess thats why you downvoted me?
    • Ken White
      Ken White about 11 years
      @Justin: I didn't downvote you. If I had, I would have said so in my last comment. However, the reason for your confusion is unclear. Your question asks "Does that mean...$,294,967,295 Words?", which is what I commented on. Your question in your comment to me says "Why is it bytes and not words?" which is something totally different. The answer to the question you asked is "No, it does not mean Words. It means bytes, just like your quote says it does.".
  • Justin
    Justin about 11 years
    So does that mean at each address there is 1 byte? I don't understand why an address could be a block of say, 6 bytes. Then you could have 4,294,967,296 * 6 mappable RAM.
  • arkon
    arkon about 11 years
    @Justin Also to elaborate a bit more, a CPU capable of accomplishing the question in your comment specifically would require a 48-bit address bus. Which I believe is what current 64-bit processors use.
  • Korpel
    Korpel over 8 years
    @Justin Sorry for invoking this question from 2013. Anyways to answer your question While each adress has 8 bit space = 1 byte in order to save there data depends on what you want to save. If you want to save a character you will need 1 byte but if you want to store an Int you would need 32 bits = 4 bytes so 4 adresses "space". The 32 bit proccessor reads 4 bytes each time hence 32 bits
  • Korpel
    Korpel over 8 years
    Hey there and sorry for invoking this thread. May i ask you how many left logical swift would it require for you to read on single character, since 1 shift moves 2 positions, 2 shifts moves 4 and 3 moves 8? Can you do 0 logical shift? thanks
  • Alexey Frunze
    Alexey Frunze over 8 years
    @Korpel I'm not sure what you're talking about.
  • Sold Out
    Sold Out over 5 years
    Excellent answer ! Thank you. I find the that second ascii drawing rather confusing, but the text is smooth and clear :)
  • Sold Out
    Sold Out over 5 years
    Just a pointer for other surfers, there is an excellent video explanation to this topic here.