What's new

schibo's recompiler doc - block addresses

Ex-Cyber

New member
schibo's recompiler doc mentions using a two-dimensional array instead of a one-dimensional array for keeping track of block start addresses for memory reasons. How does this save memory? I'm not a C expert by any stretch of the imagination, but doesn't an array with dimensions [x][y] have the same number of elements and same memory usage as a one-dimensional [x*y] array? Do the memory savings come from something else that I wasn't paying attention to? Any help is appreciated.
 

schibo

Emulator Developer
Hi,

Thanks. The doc is wrong.

But the issue is the index. If you are looking up an address such as 0x80001000, LookupTable[0x80001000] is a large array, whereas if you used LookupTable[0x8000], the table returns the base address, and then all you need to do is add the displacement, assuming the memory being looked up is contiguous.

Like this:

uint32* LookupPtr;

LookupPtr = (uint32 *) ((uint8 *) LookupTable[pc >> 16] + (uint16) pc);
 

Top