Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Size of a Word and addressing

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?

like image 921
Justin Avatar asked Mar 31 '13 23:03

Justin


2 Answers

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.

like image 172
Alexey Frunze Avatar answered Nov 02 '22 18:11

Alexey Frunze


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

like image 40
arkon Avatar answered Nov 02 '22 19:11

arkon