3 ms·
I wonder why RAM_SIZE = ADDR_SIZE * ADDR_SIZE - 1? I mean why -1?
by vadiml 11y ago
I wonder why RAM_SIZE = ADDR_SIZE * ADDR_SIZE - 1?
I mean why -1?
- bendykstra 11y agoOne address is used for memory-mapped I/O. (Writes go to the printer. Reading from this address produces a random value.)
- unwind 11y agoAnd why ADDR_SIZE squared? That just seems to work "by accident", since ADDR_SIZE is 4 it evaluates to 15. What is really meant is probably (1 << ADDR_SIZE), i.e. 2 raised to ADDR_SIZE. Of course for the value 4 it evaluates to the same thing. For 5 it would become 24 rather than 31 which I would expect, assuming it's a size in bits of course ... Now I'm confused. The file in question: https://github.com/gto76/comp-cpp/blob/e800d121e40f8acca6b9d0c4f2fe299fce012eee/src/const.hpp https://github.com/gto76/comp-cpp/blob/e800d121e40f8acca6b9d.... And the -1 seems to be explained by how the author wants to use it, it's "last valid address", i.e. not the size at all. Something I'd complain about if this were open for review, for sure. :)