[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 65C02 emulation



"Bruce Tomlin" <bruce#fanboy.net@127.0.0.1> wrote in message 
news:bruce%23fanboy.net-AC4EFA.17023530112006@news.newsreader.com...
> It all depends on how you write the emulator and what kind of I/O you
> need.  If you write it in assembly language, keep the 6502 registers in
> ARM registers, and use a 256-entry table of two or four code longwords
> each (you should be able to make a table that most instruction handlers
> will fit in, and the rest can jump out), it could be a lot faster than
> something written in plain C using switch statements.  I'm a little
> rusty on what ARM can do, but the last instruction in each handler would
> need to be an indexed jump with post-increment.  This general setup is
> how I've heard Apple did their 68000 emulator on the PowerPC, only with
> a 65536-entry jump table.

That is very similar to how "Apple2000" (Apple ][ emulator for the Amiga)
worked:

 MOVE.W (A2)+,D1 ;Get next Instruction
 MOVEA.L (A3,D1.W*4),A0
 JMP (A0) ;Off we go!!

A2 points to next 6502 instruction, loads Opcode + next byte to D1.W
A3 points at a big jump table 65536 * 4 Byte entries.
The opcode + the next byte are the index to the jump table, many entries in
the jump table are the same, since the operand byte may be another 
instruction.
A0 holds the 68K address for the instruction handler.

Some of the more common instruction sequences:
SEC
SBC xx
(for example)
could be emulated with one routine.

Made for pretty quick emulation of a 6502 on a stock 14MHz 68020 Amiga1200.

Red