I have not had the privilege of a lot of free time over the last few months, which limited my ability to explore and experiment with the eZ80 RC2014/RCBus system. And with so many things on the backlog….
But recently I have come into the possession of a little more time. And did manage to at least get one idea moving forward.
One of the original inspiration for developing the eZ80 CPU module was to potentially use it as a 2nd CPU for the Yellow MSX system – something similar to how the Turbo MSX used the Zilog R800 CPU. The Turbo MSX would switch between the 2 processors - using the faster processor for newer software, but switching to the Z80 for compatibility with older software and games.
The eZ80 and the R800 are not compatible processors though. And further, to modify the hardware design of the Yellow MSX and eZ80 Module to enable the cpu switching, via software, is certainly doable, but requires a fair bit of work (and time).
But then I had a brainwave! I wondered - is the eZ80 fast enough to ‘emulate’ a Z80? Could it interpret all the Z80 opcodes fast enough (assuming a Z80 running around the 3.5Mhz mark) and achieve the required level of compatibility. Could it run MSX game cartridges using this interpretation approach? Could I get the original PACMAN game to run using the eZ80 as the CPU?
The eZ80 is much faster than the R800, although certainly not as fast as modern 32/64Bit CPUs. (Modern PC can easily emulate Z80 based system in your browser). The eZ80 is still an 8bit CPU – it’s not super fast at all. Could it work? Would an emulator be able to achieve the equivalent performance of a 3.5MHz Z80 CPU?
You may be wondering why I did not utilise the eZ80’s Z80 compatibility mode, to just run the code natively. Well there are a few ‘buts’ with this option:
RST 00
(kind of like an exception) and effectively reboot itself.ld d,d
- which is rather pointless - a kind of no-op - if encountered by the eZ80 will cause it to handle the next instruction differently. So if some coder left such no-op instructions like these in their code, then the eZ80 will likely crash.Just this weekend, I finally managed to get my Yellow MSX system to boot with the eZ80 CPU emulating a Z80.
Perhaps a more accurate way to describe the developed solution is not so much as ‘emulating’, but rather as ‘interpreting’.
I will need to write another post describing how the code works - and the tricks employed. But it was quite a cool thing to have my MSX system boot up with the eZ80. I have yet to do any performance measurements - it seems to be fast enough - PACMAN and SALAMANDA games play just fine. Sound is synced and graphics are smooth. These are not particularly demanding games though. I need to test with some MSX2 games..
The emulated Z80 is not ‘cycle’ accurate. Some instructions may be quicker than a Z80 and others slower.
The emulator code for the eZ80 is sitting on a branch on the github repo
There are still some Z80 opcodes not implemented yet. And I need to do a lot more testing.