VOGONS


First post, by superfury

User metadata
Rank l33t++
Rank
l33t++

With the current emulation I end up on about 1.40 MIPS on a i7@4Ghz(Set to 3000 instructions/cycles per millisecond). Anyone knows how to make it comparable to Dosbox(7-8MIPS) or fake86(Pentium speed)?

My source is at https://bitbucket.org/superfury/x86emu.git

It's in the cpu directory.

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 1 of 5, by Malvineous

User metadata
Rank Oldbie
Rank
Oldbie

I haven't looked at it in detail as it doesn't look like I'd be able to compile it on my Linux machine anyway, but here are a couple of suggestions. Function calls can be expensive, so have you tried inlining all the functions for each instruction? If the compiler respects that, you could avoid a function call on each emulated opcode.

A couple of your opcodes also include conditional statements, which can incur a performance hit if the host CPU's branch predictor gets it wrong. You might want to see how often those instructions are used, and if it's a common one, see if you can replace the branch with an alternative (like an array lookup or similar.) Best to benchmark a lot though, because you can waste a lot of time doing this for little benefit!

Of course before you do any of this, it'd probably be a good idea to use a code profiler to work out exactly which parts of the code are being used the most, so you know where to concentrate your efforts. Otherwise you might end up spending time optimising something that is rarely used, making little change to the overall emulation speed.

Reply 2 of 5, by superfury

User metadata
Rank l33t++
Rank
l33t++

I've already inlined the code for CPU emulation as far as possible. The only parts that are not inlined are the external calls(functions in the modrm.c module, which can't be moved to inline in headers because of cross-platform dependencies(psp)).

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 3 of 5, by vladstamate

User metadata
Rank Oldbie
Rank
Oldbie

Hi superfury,

May I ask what software you use to report the MIPS? For my own emulator (when set in 8086 mode) I used CheckIt and TOPBENCH (which says Score 154, Pentium @ 75Mhz).

To answer to your question I use function pointers for all instruction decoders.

Regards,
Vlad.

YouTube channel: https://www.youtube.com/channel/UC7HbC_nq8t1S9l7qGYL0mTA
Collection: http://www.digiloguemuseum.com/index.html
Emulator: https://sites.google.com/site/capex86/
Raytracer: https://sites.google.com/site/opaqueraytracer/

Reply 4 of 5, by Jepael

User metadata
Rank Oldbie
Rank
Oldbie
Malvineous wrote:

I haven't looked at it in detail as it doesn't look like I'd be able to compile it on my Linux machine anyway

Hi Malvineous (I should be more active at ModdingWiki 😀

Actually it is quite painless, I went through the initial porting process and I sent Superfury the necessary changes to compile under Linux. He made a linux header in the repository (thank you for accepting feedback).

What I have done to compile it is that I just installed Code::Blocks IDE, created a C project, adding all files recursively.
Then, some SDL rotozoomer files not in default SDL library are needed, and SDL library needs to be added to build options (like in the SDL program template of Code::Blocks).

Of course this assumes many things:
-64-bit Linux (haven't tried with 32-bit), I used latest 64-bit Linux Mint with Cinnamon UI (should not matter).
-SDL runtime is installed (some distros have it by default)
-GCC installed if it isn't
-Code::Blocks installed
-Possibly something else

Reply 5 of 5, by superfury

User metadata
Rank l33t++
Rank
l33t++

@vladstamate: I'm using MIPS 1.10 for checking the emulator MIPS. I do notice that as I improve the emulator, it seems to run little bits faster(maybe because of less type conversions etc.).

I've tested using topbench just now (on Windows 10 running on a Intel i7@4.0GHz, without overclocking). It keeps switching between a Intel 8086/8088@8MHz (I'm using the default database with the downloaded application).

It switches between a Amstrad PC2086 and a IBM PCJr (8MHz) without mounted keyboard/mouse, reasonably fast beeps about 2 ticks per second?

With keyboard/mouse mounted (less frequent beeps) I get IBM PCJr (8MHz) and a Tandy 1000SX(@7.16MHz).

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io