> > As far as I can gather it has a code emitter similar to the other 68000
> > emulators except it produces C code fragments for each opcode.
> > These code fragments are then executed based on opcodes with run-time compiled
> > IL structures (I think...).
> > Yet the PDF talks about flag optimisation, and an ARM backend!
> > How can you have an x86 or ARM backend if it is producing C code fragments on
> > opcode basis and then executing them one at a time based on a run-time
> > intemediate language?
> I thought the way Generator worked was that it emulated instructions with C
> functions (generated at compile time) invoked by a sequence of CALL instructions
> (in the native processor language.)
> It could probably do flag optimization by having different functions for each
> instruction which calculate different combinations of flags (or none at all.)
> I'm not really sure, though. Email James and see what he says :) And then post
> the answer here ;)
No I think you are right - that's brilliant!!, because then you could basically run through the entire code and sort-of static recompile it at run-time but BEFORE emulation, by filling a big array of function pointers. You'd need 2x the memory of the rom BUT you could also do dead flag stuff as well (which is one of the two big overheads in C emulators)!
// Pregenerate this at compile time
static void MoveW_An_Dn()
static void MoveW_An_Dn_flags()
c=?; n=?; v=?; z=?; x=? //work out flags too
... etc for all opcodes
// Build this array at run-time from the rom data (or maybe just from basic blocks to save memory)
MoveW_An_Dm, // move.w (A4),d0 flags unused
MoveW_Imm_Dm, // moveq #$00,d0 flags unused
MoveW_Dn_Am, // movea.l d0,a6 flags unused
MoveW_Am_USP, // move a6,usp flags unused
MoveW_Imm_Dm_flags, // moveq #$17,d1 flags might be used
GENIUS! This could potentially run faster than a standard assembler core! What do you think?
Anyone else done anything like this before (apart from Mr. Ponder?)
The best thing about this type of emu is that you get a potential Static recompiler for free...!
You just do this:
MoveW_An_Dm(), // move.w (A4),d0 flags unused
MoveW_Imm_Dm(), // moveq #$00,d0 flags unused
MoveW_Dn_Am(), // movea.l d0,a6 flags unused
MoveW_Am_USP(), // move a6,usp flags unused
MoveW_Imm_Dm_flags(), // moveq #$17,d1 flags might be used
And then the compiler will optimise the crap out of the individual opcodes... I'm pretty excited about this :))
You learn something old everyday...