Pointers and the adresse bus
-
My PC is a "32 bit system". That means 32 bit address bus => the highest address is 2^32 - 1 = 4294967296 That means also 32 bit data bus. (4 Byte per word) => the maximum of adressable memory is 4 * (2^32 - 1) = 17179869184 now programming in c/c++: sizeof( char ) = 1 (byte) difference of pointers of two successive char variables : 1 sizeof( int ) = 4 difference of pointers of two successive int variables : 4 sizeof( any Pointer ) = 4 => A char pointer must contain information about which of the 4 bytes in a 32 bit word is meant, and also information of the address on the address bus. => I cannot access the maximum of adressable memory with pointers, but only a fouth of it. (or less?) AM I RIGHT??? Friedrich
-
My PC is a "32 bit system". That means 32 bit address bus => the highest address is 2^32 - 1 = 4294967296 That means also 32 bit data bus. (4 Byte per word) => the maximum of adressable memory is 4 * (2^32 - 1) = 17179869184 now programming in c/c++: sizeof( char ) = 1 (byte) difference of pointers of two successive char variables : 1 sizeof( int ) = 4 difference of pointers of two successive int variables : 4 sizeof( any Pointer ) = 4 => A char pointer must contain information about which of the 4 bytes in a 32 bit word is meant, and also information of the address on the address bus. => I cannot access the maximum of adressable memory with pointers, but only a fouth of it. (or less?) AM I RIGHT??? Friedrich
The maximum addressable memory is not 4 * (232-1), but rather (232-1), so there is no problem of the sort you describe. What a pointer stores is the address of a single byte (a
char
, roughly speaking,) not a full 32-bit word. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo -
My PC is a "32 bit system". That means 32 bit address bus => the highest address is 2^32 - 1 = 4294967296 That means also 32 bit data bus. (4 Byte per word) => the maximum of adressable memory is 4 * (2^32 - 1) = 17179869184 now programming in c/c++: sizeof( char ) = 1 (byte) difference of pointers of two successive char variables : 1 sizeof( int ) = 4 difference of pointers of two successive int variables : 4 sizeof( any Pointer ) = 4 => A char pointer must contain information about which of the 4 bytes in a 32 bit word is meant, and also information of the address on the address bus. => I cannot access the maximum of adressable memory with pointers, but only a fouth of it. (or less?) AM I RIGHT??? Friedrich
An Intel-architecture PC is a byte-addressable machine but you seem to be thinking about word-addressable machines which are quite rare nowadays. Each byte has its own memory address, so the addressable memory space for a single process (without funny tricks with segment registers) is 4 GiBytes, not 4 GiWords. All the memory space is addressable with 32 bit pointers.