3 ms·
I don't know for sure, but I believe that memory addresses are generally represented as an unsigned integer of one of a few sizes. 24MB is well over the maximum
by kbsletten 10y ago
I don't know for sure, but I believe that memory addresses are generally represented as an unsigned integer of one of a few sizes. 24MB is well over the maximum value for a 16-bit integer (approx. 65K) so they simply used the next larger size -- a 32-bit integer (max size approx. 4B) -- and figured that most of the address space being un-mapped wouldn't be a problem. This is common in most computers because the allowed memory size grows at an exponential rate with increased size for the addresses.
- rocky1138 10y agoYes, this reminds me of older computers. My Atari ST 1040 has something like 2MB of RAM but I'm sure the addressing is 32-bit, meaning that there are addresses that it can't ever reach. In fact, doing some research shows that 8-bits of the address are often ignored on the Motorola 68000 leaving a 24-bit memory address.
- coldpie 10y agoI remember reading on HN that developers would use those unused bits to carry more data around. There was so little RAM available that the unused bits in pointer addresses were useful.
- Narishma 10y agoAnd it came back to bite them when later processors used those bits.
- serge2k 10y agoThat type of thing is still done today. For example, in V8 they use the bottom 2 bits of pointers for other things. They get away with it because objects are 4 byte aligned.
- jburgess777 10y agoLast time I looked, the current 64bit Intel CPUs only used the lower 48 bits for userspace virtual addresses. This leaves 16 bits available if you want to tag your pointers with some additional information. This can be useful for saving space or using them with an 8 byte cmpxchg. This kind of trick is easier to get away with if you know exactly which CPUs your software is going to run on. Otherwise your software could break horribly when a new generation of CPU comes around.