Forum Index | FAQ | New User | Login | Search

Make a New PostPrevious ThreadView All ThreadsNext ThreadShow in Flat Mode*


SubjectAhhh! That's genius! Reply to this message
Posted byfinaldave
Posted on12/11/03 05:03 AM



> > 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
> an
> > 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)!

e.g.
move.w (A4),d0
moveq #$00,d0
movea.l d0,a6
move a6,usp
moveq #$17,d1

->
// Pregenerate this at compile time
static void MoveW_An_Dn()
{
D[n]=A[m];
};

static void MoveW_An_Dn_flags()
{
D[n]=A[m];
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)
void (*)()[]=
{
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:
switch (pc)
{
case 0x206:
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
break;
...
}

And then the compiler will optimise the crap out of the individual opcodes... I'm pretty excited about this :))


You learn something old everyday...


-
Entire Thread
Subject  Posted byPosted On
*Does Generator have a 68000 Dynarec?  finaldave12/10/03 03:35 PM
.*Re: Does Generator have a 68000 Dynarec?  Bart T.12/10/03 03:48 PM
...Ahhh! That's genius!  finaldave12/11/03 05:03 AM
...*Re: Ahhh! That's genius!  smf12/12/03 07:56 AM
....*Re: Ahhh! That's genius!  ElSemi12/13/03 07:31 AM
.....*Re: Ahhh! That's genius!  finaldave12/13/03 05:19 PM
......*Re: Ahhh! That's genius!  Bart T.12/13/03 08:31 PM
.......*Re: Ahhh! That's genius!  ElSemi12/14/03 05:18 AM
........*Re: Ahhh! That's genius!  Riff12/15/03 00:38 AM
.........*Re: Ahhh! That's genius!  Bart T.12/15/03 01:17 AM
..........*Re: Ahhh! That's genius!  Riff12/15/03 02:27 PM
...........*Re: Ahhh! That's genius!  Bart T.12/16/03 03:20 AM
...........*Re: Ahhh! That's genius!  finaldave12/15/03 03:48 PM
............*Re: Ahhh! That's genius!  Bart T.12/15/03 04:30 PM
.............*Re: Ahhh! That's genius!  Kayamon12/18/03 08:56 AM
..............*Re: Ahhh! That's genius!  finaldave12/18/03 09:36 AM
...............*Re: Ahhh! That's genius!  smf12/19/03 04:33 AM
.............*Re: Ahhh! That's genius!  finaldave12/16/03 05:16 AM
..............*Re: Ahhh! That's genius!  Bart T.12/16/03 01:04 PM
...............*Re: Ahhh! That's genius!  finaldave12/16/03 03:40 PM
................*Re: Ahhh! That's genius!  smf12/17/03 06:33 AM
.................*Re: Ahhh! That's genius!  finaldave12/17/03 06:39 AM
..................*Re: Ahhh! That's genius!  smf12/17/03 09:57 AM
...................*Re: Ahhh! That's genius!  finaldave12/17/03 12:39 PM
....................*Re: Ahhh! That's genius!  smf12/17/03 02:59 PM