I'm writing a virtual machine/interpreter for a made-up assembly language. I've just realised that 90% of the GUI code has to do with handling a doubly-linked-list of SDL_Surface pointers, and only 3 functions actually have anything to do with the GUI proper...
You could try something like that. At the moment I'm writing a script to make adding opcodes less painful (you type in an opcode (e.g. "MOV") and then a list of what arguments it takes (e.g. "RR RM RI MR MM MI" ("Register<-Register, Register<-Memory, Register<-Immediate, Memory<-Register, Memory<-Memory, Memory<-Immediate" (that's dest, source)) and it comes up with a list of opcodes, organizes them alphabetically, and then puts the names in an enumerated list (after NOOP, which has the value 0x00) and then it puts them into a struct).
Very nice chrisname, a friend of mine is actually writing an x86 assembly interpreter + ide for his thesis project. Mostly because all of the second years do very badly in assembly in the comp sci program at my school and he wants to develop a tool to help the students out.
I tried an x86 emulator a while ago and it did not go well. I got sick of all the instruction listings being in alphabetic order (rather than in order of their opcode) so I gave up.
Aslo my current VM is riddled with SEGFAULTs. I'm wondering if I might have been drunk when I wrote it or something.
Yeah, but I don't really know Perl. I learnt a little basic Perl but I've completely forgotten it. Admittedly, I did think it was a very nice language (despite the Perl code you see on the Internet!)
I'm writing my own instruction set anyway. I've written a script to generate a list of opcodes arranged alphabetically when you give the opcode's name (e.g. MOV) and a list of arguments (e.g. "IM IR MM MR RM RR", which would be "Immediate->Memory, Memory->Memory, Memory->Register, Register->Memory, Register->Register" (source->dest syntax)).
Also, I've fixed all the SEGFAULTs. There was a problem with one of the functions in the main.c file that must've been messing up the stack or heap. I can't remember exactly. I also had to fix a memory leak in the GUI code (I can't believe that I didn't realise allocating an SDL_Surface pointer in every frame and not freeing it until the program closed would cause excessive memory consumption (it went up to 2.8 GiB in a few seconds)). Now I've sorted out all the obvious bugs (there might be a few of those horrible sneaky ones that don't do anything until you add more code) all I have to do is finish writing the instruction set, implement all of the functions for it, write an assembler for the assembly language (that shouldn't be too difficult, since I'm going to make it very simple) and then write some programs. At some point I might also write a compiler for a high-level language (maybe an esoteric language) and then stick it all together.