
Think back to a time when computers were simpler. Your eyes ache as you look straight into the green light emitting from your monochrome monitor. You load up your Multi User Dungeon program, and after gaining a level, you post on the alt.hacker Usenet group about your dream of having a computer in every household. These were the times of DOS, Apple II, a minimal form of Unix, and even more tiny (sometimes even homemade) computers. Something was magical about these minimal machines. Something was different.
These computer users have now grown, and so has the technology industry. No longer can you post on a Usenet group without facing loads of spam, no longer can the word ?hacker? be used without striking fear into the hearts of non-technical-savvy people, and no longer can you war-dial. But there are a few select people out there who miss these times, and who long to bring back the glory of these simple silicon devices to the present day. These retrocomputing fans may restore the deteriorating hardware of an old computer, but many encourage the development of emulators, which can run the software of the past on today's high-speed computers.
I have long wondered how emulators work, and how to program one myself. Let me tell you, it is no easy task. It will take a long time, and a lot of patience in order to relive the memories of past electronics. But even those who are ready for the challenge will have a hard time finding documentation on how to begin. Information on emulator structure alone is hard enough to find!
This document will discuss the creation of an interpreting emulator. There are several different types of emulators, but this type is probably the easiest to write, as it doesn't require the recompiling of code.
Before I discuss how to program an emulator, one must know the design of a computer like the back of their hand, and in particular, the computer or video game console that they plan to emulate. This is the only way you will be able to create what you long for. The following is a brief (and I mean brief) description of how a typical computer works. The actual process is much more complicated, but a basic computer will include these elements.
Computers read instructions coded in the form of binary to tell them what to do. The parts of the computer then react to a specified command, and often store a number or value in the memory of the computer, for use in a later process or manipulation. CPUs can store numeric values in what are called registers, and values from the memory can be loaded into these registers. When in a register, a value can undergo a variety of mathematic processes, including addition and subtraction. These registers are what define a computer.
There are limits to how large a number a computer can process. It all depends on the bit type of a CPU. 8-bit CPUs can store numbers up to 255, 16-bit can store up to 65535, and 32-bit stores up to 1, 677, 721. The most commonly emulated computers are 8-bit, as the small numeric limits are easier to code with.
The binary counterparts of these computer instructions are stored in memory, and on the modern computer, a file. That's right, ?resume.txt? actually holds the ASCII binary values of each letter in that job resume. There's a lot more to it than just text.
Now that you know how a basic computer will work, we can begin the discussion of how to create an emulator for a certain computer. Keep in mind that creating an emulator will become more complex if you choose to emulate a complex computer. Computers often include many peripherals that you will have to emulate, too. If your computer includes memory, lights, and a keyboard, you will probably have to emulate them all.
Stay tuned for part two, where I give an example of how to code an emulator!
Would you like to be a Community Voices blogger? If so, please send a letter of interest and a sample blog entry (what you would post here if you were already a blogger for us) to forums@pcworld.com. We'd love to hear your perspective.