The MASM Forum

Miscellaneous => The Orphanage => Topic started by: daydreamer on May 01, 2021, 05:55:00 PM

Title: Emulator benchmarks???
Post by: daydreamer on May 01, 2021, 05:55:00 PM
Anyone timed emulators?
So 3.5 ghz cpu is capable of emulate x MHz computer?
If I put setting to max, 1 emulated clock cycle takes y clock cycles to do on real cpu?
Ofcourse it's more complicated because emulating multiple hardware,cpu,graphics card,sound card
Title: Re: Emulator benchmarks???
Post by: BogdanOntanu on May 02, 2021, 10:25:09 AM
Quote from: daydreamer on May 01, 2021, 05:55:00 PM
Anyone timed emulators?
So 3.5 ghz cpu is capable of emulate x MHz computer?
If I put setting to max, 1 emulated clock cycle takes y clock cycles to do on real cpu?
Ofcourse it's more complicated because emulating multiple hardware,cpu,graphics card,sound card

I wrote a few ;)

It depends on a few key issues.

1) What exactly do you want to emulate?
================================
1a) Emulate a few ASM instructions and loops procedures? (many AV will do this in order to decrypt or de-obfuscate malware code)
1b) Emulate a full application but not the full hardware or full OS (again AV usage for rogue applications)
1c) emulate the full hardware / CPU and be able to run fully Windows 10 or Linux on it? (like VirtualBox, VMWare, QEMU)

2) How you plan to implement it?
=============================

2a) A simple C code with "IF opcode == XOR and arg1 == EAX THEN fn_xor(ctx.regs.eax, arg2)"

This will be slow in 50-150Mhz range and a LOT of work for all instructions but normally "easy" to make and will emulate Intel on ARM or MIPS for example. (Bochs style)

2b) Optimize by re-compile of the original ASM code to other similar code BUT avoid emulate as above the privileged instructions.

Much faster, 500-1800Mhz since most code will be run natively but requires re-compilation and code analyze for multiple CPUs
(early QEMU style)

2c) Use new VMX virtualization extensions and ring-0 mode for each CPU and allow code to run "almost natively" and call your callbacks / return to ring_0 virtualizer when privileged code has to be executed.

This is super fast, depends on hardware support, speed as big as 4Ghz or normal CPU run or even faster sometimes.
(the new Virtual Box, WMVare or QEMU style)

All can have bugs (but mostly options 2b and 2c) and expose the host system to an attacker :D

Title: Re: Emulator benchmarks???
Post by: daydreamer on May 03, 2021, 03:22:47 AM
But 2a with jumptable

Some emulators seem to be about emulate right timings on old hardware for old retrogames to work correctly, but might break that if it instead should emulate a P4 instead of 486?

But if i run on low setting on dos emulator, it's more of a challenge  than run on new 4.5 ghz native cpu
One thing I noticed is when running emulator is best use of special energy setting which runs like turbo is turned off,more kinda fixed cpu frequency
Title: instead of emulator,use old computer for dos?
Post by: daydreamer on June 11, 2021, 09:45:24 PM
I was thinking,maybe try to use old unused computer for DOS?or linux with ability to use ports
with 2ghz and right OS,it would be possible to do the old printer port controlling things,but with 2ghz it would have the grunt for image recognize software,from webcam?