You probably know what an emulator is. An emulator is a computer program which emulates (duh) another computer system. For example, you can download a GameBoy emulator, rip your old cartridges to a computer file and play the games without needing a real GameBoy. Usually, the system a platform is emulated on (in this case: a PC) is (much) more powerful and capable than the machine it emulates: seemingly, it takes at least a 32-bit machine running at some 30MHz to emulate the puny 8-bit Gameboy running on 4MHz.
There is, however, nothing stating that the emulated machine has to be less powerfull than the one running the emulator. In computer science, the concept of being Turing-complete illustrates that. Turing-complete means that a certain machine can emulate a Turing-machine, and it is proven that a Turing-machine can emulate any Turing-complete machine, given enough storage. Thus, in theory, the Gameboy could just as well emulate the PC as the other way around, given enough storage. Ofcourse, a real-time emulation would be out of the question with the speeds involved, but if you'd wait long enough, you should get the same results.
All that is nice in theory, but I wanted to try it out once. (Besides: I had not written emulator code for a long time and I remember it as being fun to see someone elses binaries running merrily on hardware for which it wasn't intended.) But what to emulate with what? Theoretically, I could emulate a PC with a 4004, but that would take a hellovalot of development time and I didn't want to prove myself that badly.
In the end, I decided on emulating a CP/M machine on an AVR. CP/M is an OS which runs on the Intel 8080-platform or compatible chips, the most known of those being the Z80. The AVR is a machine of which I know the architecture quite well by now. Comparing these cpus is a bit hairy: while the Z80-machines are CISC, have more 16-bit oriented instructions and usually have a heap of RAM connected to them, the AVR runs much quicker with its 20MHz and 1MIPS/MHz. Even with the CPUs being this close, for the purpose of a proof-of-concept it was good enough.
1 Next »