How many bits of address is required (for the program counter for example) in a byte-addressed computer with 512 Mbyte RAM?
What does the formula look like?
How is this connected with the fact that 32 bits can address no more than 4 GB RAM?
5
You need log2(n) bits to address n bytes. For example, you can store 256 different values in an 8 bit number, so 8 bits can address 256 bytes. 210 = 1024, so you need 10 bits to address every byte in a kilobyte. Likewise, you need 20 bits to address every byte in a megabyte, and 30 bits to address every byte in a gigabyte. 232 = 4294967296, which is the number of bytes in 4 gigabytes, so you need a 32 bit address for 4 GB of memory.
3
Existing answers have explained that the formula for addressing ram is 2^BITS = Addressable ram, but have not explained why.
Consider a system with 2 bits. It can address 4 bytes of ram as follows:
Byte 0: 00
Byte 1: 01
Byte 2: 10
Byte 3: 11
For each additional bit, we can address twice as much memory. E.g., add a 0 bit to each for bytes 0-3, then add a 1 bit for bytes 4-7. We address byte X by using a bit arrangement corresponding to X in binary.
You need the log (base 2) of the N bytes in order to address N bytes of RAM directly.
4 GB = 2^32 bytes
log_2( 2^m ) = m
so
log_2( 2^32 ) = 32
So a 32-bit address lets you directly reference 2^32 bytes (4 GB). A 64-bit address lets you directly reference 2^64 bytes (16 exabytes).
0
How many bits of address is required (for the program counter for
example) in a byte-addressed computer with 512 Mbyte RAM?
There is no answer.
For modern systems software uses virtual memory, and virtual memory has nothing to do with physical memory. For example, you might have 512 MiB of RAM, 1.5 GiB of swap space, and 2 GiB of memory mapped files.
For most systems that have about 512 MiB of RAM; you’d typically want/expect 32-bit addresses and 32-bit instruction pointer (and have 4 GiB of virtual address space per process, including space reserved by kernel).
Note that “amount of RAM” also has nothing to do with actual physical address size or minimum physical address size. A computer with 512 MiB of RAM, 4 MiB of ROM, and 512 MiB of memory mapped devices (video cards, etc) may need a minimum of 2 GiB of physical address space (and may actually have 4 GiB of physical address space).
1
It depends not on the amount of RAM, but on the address space. A 64 bit processor with 512 MB RAM and virtual memory supported by a 5 TB hard drive needs at least 43 bits for addresses. Now if you support sparse allocations then you need more.