<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Mon, 18 Jul 1994 16:23:22 EST
From   : Stephen Quan <quan@...>
Subject: Re: Beeb Emulators

> I haven't tested this for speed against the table method. It suprised me
> though to find that all of these varying speeds of this apparently common
> operation appear to have virtually no bearing on the final speed. Obviously
> it's not as common as I thought.
> 
>   James

In laying out the ground work for my mark-3 emulator, I put together 
a few test programs.  Again, I am basing all my results on the 256^3
loop example.  My version 256^3 assembly loopp has a runtime execution
of 33,685,245 instructions [I got my emulator to trace and count it!]

My DOS version of the emulator executed this in about 59 seconds.
Then I started writing my test program that has this.

    unsigned PC;
    main()
    {
      long l ;
      for (l=0; l<33685245L; l++
      {
        opcode = 0xa9;
        switch (opcode)
        {
          case 0x00 : PC += 0x00; break; /* fake execution of opcode 0x00. */
          case 0x01 : PC += 0x01; break; /* fake execution of opcode 0x01. */
                   ....
          case 0xff : PC += 0xff; break; /* fake execution of opcode 0xff. */
        }
      }
    }

This code executed on my PC in 50 seconds when compiled exactly the
same way as my emulator.  Meaning that the execution cycle of our
emulator only account for 9 seconds in 59.  If optimisations are to
be done, then it is not to be in the execution of code, but rather
in the fetching of an opcode and the opcode's selection of some code.
This was why I needed to investigate 256 branching as opposed to using
one big switch statement in my code.

So far, I have not been able to find any code that beats having one
switch statement.  I do have alternatives that come with comparable
but slightly slower speeds.  Only on a sparc-2 did one of my alternatives
beat it, but that difference was 2 seconds.  Not enough to make a
real difference.

Actually, I cannot find the sheet of paper I wrote all my statistics
and timings on it, but I believe I remembered them correctly [just
needed to remember 59 and 50!].  The compiler I used was DJGPP and
I compiled my emulator and test programs using the -O flag.  I also
used Borland's C++ compiler and it actually showed numbers like 77/77
implying that the execution of code had zilch effect over 33 million
emulated instructions!  hmrph!
-- 
Stephen Quan (quan@...                 ), SysAdmin, Analyst/Programmer.
Centre for Spatial Information Studies, University of Tasmania, Hobart.
GPO BOX 252C, Australia, 7001.  Local Tel: (002) 202898 Fax: (002) 240282
International Callers use +6102 instead of (002).
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>