1

For a 4G ram, there is 4 * 1024 * 1024 * 1024 * 8 = 2^(32+3) bits. My question is how could a 32-bit PC can access a 4G memory. What I can think of this is "a byte is the storage unit, one can not store a data in a bit". Is this correct?

Another question is: in such PC, does a pointer always have size 32 bit? It seems reasonable for me, because we have 2^32 storage units to store the data. But in this answer and the next with their remarks, this is said to be wrong. If it is wrong, why?

Community
  • 1
  • 1
user565739
  • 1,302
  • 4
  • 23
  • 46

2 Answers2

2

Individual bits are accessed by reading the address of the byte containing it, modifying the byte and writing back if necessary.

In some architectures the smallest addressable unit is double word, in which case no single byte can be accessed "as is". Theoretically one could design an architecture that would address 16 GB of memory with 32-bits of unique addresses. And similar things happened years ago, when the addressable units of a Hard Drive were limited to bare 2^28 units of 512 byte sectors or so.

It's not completely wrong to say that PC's have 32-bit pointers. That's just a bit old information, as the newer models are internally 64-bit systems and can access depending on the OS up to 2^48 bytes of memory. Currently most existing PCs are 32-bit and nothing can be done about it.

Well, StuartLC remainded about paging. Even in the current 32-bit systems, one can use 48-bits of addressing using old age segment registers. (Can't remember if there was a restriction of segment registers low three bits being zero...) But anyway that would allow 2^45 bytes of individual addresses, out of which just a small fraction could ever be in the main memory simultaneously. If an OS supporting that addressing mode was developed, then probably full 64 bits would be allocated for the pointer. Just like it is today with 64-bit processors.

Aki Suihkonen
  • 19,144
  • 1
  • 36
  • 57
0

My question is how could a 32-bit PC can access a 4G memory

You may be confusing address bus (addressable memory) and the size of the processor registers. This superuser post details the differences.

Paging is a technique commonly used to allow memory to be addressed beyond the size of the OS's capabilities, e.g. see PAE

does a pointer always have size 32 bit

No, not necessarily - e.g. on 16 bit DOS and Windows, and also pointers could be relative to a segment.

Can one can not store a data in a bit?

Yes, you can, e.g. in C, bit packing in structs can be done, albeit at the cost of performance and portability.

Today performance is more important, and compilers will typically try and align data to its machine word size, for performance reasons.

Community
  • 1
  • 1
StuartLC
  • 104,537
  • 17
  • 209
  • 285