Z80 Emulation Engine

bearophile via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Sun Apr 20 06:08:01 PDT 2014


ketmar:

> sorry, it uses GDC @attribute("forceinline") feature, so you 
> need latest GDC to build it. it's not strictly necessary though 
> (speed optimizations?

Have you performed a benchmark with and without that attribute?


> http://repo.or.cz/w/zymosis.d.git

In this kind of code computed gotos could help performance.


> struct { ubyte c, b; };

Struct definitions in D don't end with the semicolon.


> @property final void iff1 (int v) nothrow { riff1 = (v != 0); } 
> /** set interrupt flip-flop 1 */

I suggest to omit the space between the function name and its 
arguments. And if you want you can also add an "in":

... iff1(in int v) nothrow ...


> { rregR = ((rregR&0x7f)+1)|(rregR&0x80); }

Better to add spaces around those operators. And perhaps it's 
better to use enum values instead of magic constants.


>   final void exec () {
>     ubyte opcode;
>     bool gotDD, trueCC;
>     int disp;
>     ubyte tmpB, tmpC, rsrc, rdst;
>     ushort tmpW = 0; /* shut up the compiler; it's wrong but 
> stubborn */
>     /* main loop */
>     while (rtstates < rnext_event_tstate) {
>       if (rCallPager) pager();
>       if (rCheckBPs && checkBP()) return;
>       rprevpc = rorgpc;
>       rorgpc = rpc;
>       /* read opcode -- OCR(4) */
>       opcode = fetchOpcode();
>       rprev_was_EIDDR = 0;
>       disp = gotDD = false;
>       rdd = &rhl;
>       if (rhalted) { --rpc; continue; }
>       /* check for I[XY] prefix */
>       if (opcode == 0xdd || opcode == 0xfd) {

I suggest to add an empty line before the line of comment.
And I suggest to use 4 spaces as indent unit.


> static __gshared ubyte parity_tbl[256];

Better to use the D syntax:

static __gshared ubyte[256] parity_tbl;

Bye,
bearophile


More information about the Digitalmars-d-announce mailing list