Recently I have been emulating the Nintendo DS, both on my x86 Windows/macOS machine and on my ARM device (currently Android, but I would also like to try on a Linux desktop with ARM CPU.)
I find that I get much better performance on the ARM device.
Has this got anything to do with architecture? I know that the DS also has an ARM processor. Does this make the emulation easier on ARM devices? Sort of something in between emulation and virtualisation? Or is it most likely due to some other factor?
Best Answer
Yes, it has.
Without trying to bore you with technical details, running code is a lot like following a cook book. Meanwhile, code that was written for a different platform is a lot like a cook book written in a foreign language.
Sometimes, translating an instruction from one language to another is simple. Sometimes, what can be expressed in a single word in one language, requires a lecture on philosophy in another. And sometimes, you might need cooking tools that are incredibly common overseas, but not where you live.
The closer the cook book's language is to your own, the easier it will be to follow. That is why an ARM CPU achieves better performance in emulating another ARM CPU, than a CPU of a completely different architecture.
You could put it that way, though technically it is still 100% emulation, 0% virtualisation.
Virtualisation is when the code can be executed natively (directly) on the CPU. Even on an ARM CPU, you can't simply run NDS code natively. Some of the reasons include:
To say nothing of the things unrelated to the CPU, which still need emulating.
Not in this case, but it's also possible.
In theory you could design a CPU that has all the same capabilities, bugs, and quirks as the original NDS CPU, but uses a completely different architecture. If that CPU also happens to be faster and more efficient than a regular ARM CPU, you would end up with a non-ARM CPU that can emulate the NDS CPU better than a real ARM CPU ever could.
But that's purely theory. In reality, it'd probably be easier to include an FPGA (Field Programmable Gate Array), and program it to be a perfect replica of the NDS CPU. In that case, we wouldn't even need to emulate anything anymore (unless we want convenience features like graphics upscaling, fast forwarding, etc.), except maybe some of the NDS' unique features, like detecting whether the lid has been closed.