In article <>,
says...
> Grant Edwards wrote:
>
> >Yikes. Since you've never written an emulator, I would have
> >recommended starting with a decent architecture. Something like
> >a PDP-11 or 6809 or Z80. The '386 is a really nasty bit of
> >work. It's 3 or 4 badly designed processors rolled into one.
>
> Agreed.
>
> I wrote a Z80 simulator (I believe that the correct term for this thread's
> topic is "simulator" rather than "emulator".) 20 years ao in 8088 assembler
> on an 8 MHz AT&T 6300 that, at the time, had two 5.25" floppies and no hard
> disk!
>
> I used a rather straight forward (brute force?) method of allocating data
> structures for the internal registers and look up tables for the op-codes.
> The tables where used to jump to functions that "executed" the op-codes.
> An Intel hex file decoder read program files into the simulated Z80 memory
> space.
>
> As usual, the hardest part was the user interface, especially the displays
> of registers, and memory and I/O spaces. Interrupt generation was the
> program's weak point and the thing I most planned to improve but never
> got around to.
>
> The greatest benefit of writing this program was the education concerning
> the Z80's internals. I was writing embedded Z80 systems so this was a
> good thing!
>
> I had long thought that I had lost the source to this program but, in a
> office renovation, I recently came across a disk that appears to contain
> it. The trouble is that I no longer have a machine with a 5.25" floppy
> drive. I might have to buy such a drive on eBay soon and see if the disk
> is still readable!
>
>
I did the same thing for the 68K processor. I also simulated a simple
serial port and a few interrupts. As you say, the most difficult part
was the user interface. My simulator was done on a Macintosh and worked
well enough that I used it when I taught an introductory course on
computer architecture. It turned out to be most useful in illustrating
what happens in memory when you use stack-based parameters for
subroutines. It beat the heck out of keeping track of the stack with
paper and pencil!
My simulator would interpret M68K assembly language in a text file--
stepping through the source code and showing effects on registers
and memory. It was cool at the time (mid 80's), but now you can
get a better simulator with just about every IDE designed to
do cross-compilation and debugging with an embedded processor.
Mark Borgerson