How a CPU’s architecture determines the size of its memory space, how memory addresses work at the byte level, and how these addresses are represented in binary and hexadecimal formats, showing the maximum memory each architecture can handle.

A 32-bit CPU architecture means that the process memory space is represented using 32 bits. The lowest memory address in this space can be visualized in binary as 0000 0000 0000 0000 0000 0000 0000 0000. Following the same logic, the highest memory address in binary is 1111 1111 1111 1111 1111 1111 1111 1111.

Memory Space

By convention, memory addresses are often written in hexadecimal format. In this notation, the lowest address is 0x00000000 and the highest address is 0xFFFFFFFF, since each group of four binary digits corresponds to a single hexadecimal digit, with 0000 equaling 0x0 and 1111 equaling 0xF.

The highest address in a 32-bit memory space can also be expressed as 2^{32} - 1, since the address count starts from 0, or as 4,294,967,295 in decimal. Using this, we can calculate the total size of the memory space as follows:

Binary representationPower of 2CalculationDecimal representation
0000 0000 0000 0000 0000 0000 0000 0000000
0000 0000 0000 0000 0000 0000 0000 00012^{0}11
0000 0000 0000 0000 0000 0000 0000 00102^{1}2 x 12
0000 0000 0000 0000 0000 0000 0000 01002^{2}2 x 24
0000 0000 0000 0000 0000 0000 0000 10002^{3}2 x 2 x 28
0000 0000 0000 0000 0000 0000 0001 00002^{4}2 x 2 x 2 x 216
0000 0000 0000 0000 0000 0001 0000 00002^{8}16 x 16256
0000 0000 0000 0000 0001 0000 0000 00002^{12}16 x 16 x 164,096
0000 0000 0000 0001 0000 0000 0000 00002^{16}16 x 16 x 16 x 1665,536
0000 0000 0001 0000 0000 0000 0000 00002^{20}16 x 65,5361,048,576
0000 0001 0000 0000 0000 0000 0000 00002^{24}16 x 1,048,57616,777,216
0001 0000 0000 0000 0000 0000 0000 00002^{28}16 x 16,777,216268,435,456
1111 1111 1111 1111 1111 1111 1111 11112^{32} - 116 x 268,435,456 - 14,294,967,295

In comparison, the highest memory address of a 64-bit architecture would be:

Binary representationPower of 2CalculationDecimal representation
1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 11112^{64} - 1268,435,456 x 268,435,456 - 118 446 744 065 119 617 025

So what exactly does this memory space mean?

Each memory address corresponds to 1 byte in memory. For example:

Address (binary)Address (hex)Data (binary)Data (hex)
0000 0000 0000 0000 0000 0000 0000 00000x000000000000 00000x00
0000 0000 0000 0000 0000 0000 0000 00010x000000010000 11110x0F
0000 0000 0000 0000 0000 0000 0000 00100x000000020001 00000x10
0000 0000 0000 0000 0000 0000 0000 00110x000000030001 00010x11
0000 0000 0000 0000 0000 0000 0000 01000x000000040001 00100x12
0000 0000 0000 0000 0000 0000 0000 01010x000000050001 10100x1A
0000 0000 0000 0000 0000 0000 0000 01100x000000060001 11110x1F
0000 0000 0000 0000 0000 0000 0000 01110x000000070010 00000x20
0000 0000 0000 0000 0000 0000 0000 10000x000000080010 01000x24
0000 0000 0000 0000 0000 0000 0000 10010x000000090010 11110x2F
0000 0000 0000 0000 0000 0000 0000 10100x0000000A0011 11110x3F
0000 0000 0000 0000 0000 0000 0000 10110x0000000B0100 11110x4F
0000 0000 0000 0000 0000 0000 0000 11000x0000000C1000 11110x8F
0000 0000 0000 0000 0000 0000 0000 11010x0000000D1010 11110xAF
0000 0000 0000 0000 0000 0000 0000 11100x0000000E1111 11110xFF
0000 0000 0000 0000 0000 0000 0000 11110x0000000F1010 10100xAA
0000 0000 0000 0000 0000 0000 0001 00000x000000100101 01010x55
0000 0000 0000 0000 0000 0000 0001 00010x000000111001 10010x99
0000 0000 0000 0000 0000 0000 0001 00100x000000121110 11100xEE
0000 0000 0000 0000 0000 0000 0001 00100x000000131100 11000xDD

A 32-bit CPU can reference up to 2^{32}, which equals exactly 4 GB of memory (4,294,967,296 memory locations). This is called addressable memory and it is the maximum amount of memory that a CPU can reference using its addresses.

Physical and Addressable Memory

Physical memory is the actual RAM installed in the system and it is often less than the maximum addressable memory. Some addresses are reserved for system devices or hardware I/O, so not all addresses map to physical RAM.

In comparison, a 16-bit CPU can address up to 65,536 bytes, which equals 64 KB of addressable memory, while a 64-bit CPU can theoretically address up to 18,446,744,065,119,617,025 KB, or 16,384 PB of memory.

Physical and Virtual Memory

Operating systems use virtual memory to allow processes to work as if they have the full addressable space, even if physical RAM is smaller.

For 32-bit architectures virtual addresses go from 0x00000000 to 0xFFFFFFFF. This does not correspond to physical RAM addresses. Multiple processes can have the same virtual addresses that map to different physical memory locations.

Physical RAM is shared among all processes. Virtual addresses are translated to physical addresses by the CPU using page tables. So, for example, the stack of one program isn’t actually at the same place in RAM as the stack of another program, even if they both see 0xFFFFFFFF in their own virtual space.

Endianess

When a CPU stores values larger than one byte, such as 2-byte, 4-byte, or 8-byte numbers, it must decide the order in which the bytes are stored in memory. This ordering is called endianness:

  • Big-endian: the most significant byte (MSB) is stored at the lowest memory address.
  • Little-endian: the least significant byte (LSB) is stored at the lowest memory address.

For example, using the table above, the values would be arranged differently in memory depending on the endianness.

AddressData
0x000000000x000F1011
0x000000040x121A1F20
0x000000080x242F3F4F
0x0000000C0x8FAFFFAA
0x000000100x5599EEDD

While in litte endian, it would be:

AddressData
0x000000000x11100F00
0x000000040x201F1A12
0x000000080x4F3F2F24
0x0000000C0xAAFFAF8F
0x000000100xDDEE9955

As another example, the 16-bit value 0xCAFE would be stored as FECA0000 in little-endian format and as 0000CAFE in big-endian format. Note that the leading zeros are typically displayed when showing memory contents in fixed-width formats.

Word Size and Memory Access

The word size of a CPU refers to the number of bits it processes or moves at a time. For example, a 32-bit CPU works with 32-bit (4-byte) chunks, while a 64-bit CPU works with 64-bit (8-byte) chunks. Larger word sizes allow the CPU to handle bigger numbers and process more data at once, improving performance.

Even though memory is addressed one byte at a time, CPUs typically read and write data in units of their word size. To support this, memory is often organized and accessed in aligned blocks, meaning that multi-byte values are stored at addresses that are multiples of the CPU’s word size. Aligned access is faster and more efficient, while misaligned access can slow down execution or even cause hardware exceptions on some systems.

Word size also determines how the CPU interprets multi-byte values in memory. When reading a word, the CPU must know the system’s endianness, whether the most significant or least significant byte comes first, so it can reconstruct the original value correctly.