I think you are a little unclear as to the scope of this project, at least with regard to the name.
the emulator executes binary code and nothing more. The emulator does not include an editor (this is a development tool), as well as assembler (the same). The assembler has a duty to perform syntax checking and translation, so the emulator only has a relatively simple job of executing pre-validated legal code.
It looks like you want to create a complete IDE. This will wrap a lot of GUI around the editor, assembler and emulator. I would leave this step last.
As for your questions regarding the emulator itself:
As the working memory of the emulator, you can use an array of up to (for example) 64 KB. You use variables in your program to emulate registers. I would use unsigned char * to emulate the program counter and int for most other things ...
The operation is quite simple: start the program counter at 0 (or a predefined download location) and run a cycle that retrieves instructions through this pointer and applies any operation related to the instruction to the register and memory. A simple implementation will focus around the huge switch , which includes all possible command codes.
As I said, your emulator does not need to worry about illegal instructions, because the assembler should not do anything. You may have your program (i.e. the main loop) if it gets into an illegal operation.
Similarly, your emulator does not need to worry about overflowing a range, index or size ... which is also an assembler problem or maybe a linker, if you have one.
Update: A few pointers right here in SO:
Emulator infrastructure
Carl Smotricz
source share