![]() ![]() Now we need to associate the entry point of a block inside that buffer with the pc in the emulated system where that block starts. That works surprisingly well, as it fits the code of most games and we still do it like this. The way the generated code is stored might sound crude but it's simply a large buffer (32 MB) which we fill from bottom to top, once it's full we reset everything. melonDS's block cache has gone through a few iterations, though originally I just copied desmume's which is the one I'm going to describe here, we get fancier in the future. ![]() The pivot of the second question is the block cache. So after a branch instruction we end a block. While this all could be handled to generate even more efficient code (we do this to some degree, more on that later), for now we leave this out. We need to keep in mind that branch instructions can bring the pc to any other places, including somewhere inside this block and can also split the execution into two paths if they're conditional. The last thing to consider is that we can't just take the next n instructions from the first one and compile them into a block. For this reason the maximum block size is adjustable in desmume (and some games require setting it below a certain value) which is the case for melonDS as well, though we have some more hacks haven't heared of a game breaking at too high block sizes yet ). when an interrupt occured or the timeslot of the cpu is over, while a JIT block has to be executed until the end. This has one problem: with the interpreter we can leave or execute at another point after every instruction, e.g. So it's not possible to jump into a block half way in, instead we would create another block which would start at that point. This makes the code generation significantly more easier for us, but also the generated code more efficient. Note that most of this applies for cached interpreters as well.įirst we say a block can only be entered via the first instruction and left via the last one.
0 Comments
Leave a Reply. |