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