News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Assistance with private emulator

Started by SoraK05, August 19, 2014, 02:17:16 AM

Previous topic - Next topic

SoraK05

Hello.
There is an emulator I am assisting and I am looking for any individuals with ASM experience to lend some advice considering relatively limited room/speed for this. It is not x86 but can assist with a version and any suggestions for less steps is appreciated and I would prefer to communicate through pm for any details.

Thanks.

qWord

Quote from: SoraK05 on August 19, 2014, 02:17:16 AMI would prefer to communicate through pm for any details.
So this is a professional request?
MREAL macros - when you need floating point arithmetic while assembling!

SoraK05

Well it is free work in free time, but i'd prefer to keep its details a bit more private :)
If anyone is interested in assisting with optimizing a current emulator thing and also for contribution towards x86 version can pm me. Emulator is currently quite functional but can do with some speedups.

SoraK05

There is actually something very specific at the moment I'd like to optimize and I know how to do this in c++ but not in ASM.
It is to check specific bits like 'if first bit is 0', then 'if second bit is 1' for example instead of reading an entire byte to confirm contents and spare some steps by looking only at specific bit branches.

I have the general information and ASM instructions, but not sure how to check specific bit branches instead of the whole byte with ASM.
It shouldn't vary too much from x86 and any suggestion is appreciated on how to look at specific bits for a branch and proceed for specific instructions instead of an entire byte (for example if all instructions being checked only start with '0' bit instead of checking an entire 8 bit string for the instruction I am looking at and sparing 7 bit steps worth all round at the core on many instruction checks a second).

Right now a whole register content is checked to confirm a specific instruction when read and I would rather check specific bits suiting what I am checking than read the whole content.

qWord

Instead of checking single bits for categorization, it is probably faster to use the opcode byte as index in a table of function pointers and then call the corresponding handler.
MREAL macros - when you need floating point arithmetic while assembling!

SoraK05

If you are checking a 32 bit instruction for example against a few possible opcodes to do something respectively, this means checking the 32 bits multiple times against a few 32 bit opcode options in ifs on every instruction being read.

What I am thinking is something similar to 'if first bit is 0' knowing that all the possible opcodes you want to check all start with 0 then you can stop and not bother with checking that 32 bits multiple times for opcode possiblity ifs on every instruction check.

habran



     
    shr eax,1
    .if (CARRY?)
        do something
    .endif
Cod-Father

Gunther

You have to know the facts before you can distort them.

dedndave

or use the BT instruction

honestly, i would be inclined to use a look-up table
it may not be smaller, but it would probably be a heck of a lot faster

jj2007

Quote from: dedndave on August 21, 2014, 02:15:38 AM
honestly, i would be inclined to use a look-up table
it may not be smaller, but it would probably be a heck of a lot faster

Depends on the CPU: if there is a given number of bits or bytes defining the opcode, e.g. 6A = push 8bit value, then it could be fast and easy indeed.

dedndave

even if the opcode is multiple byte-length
use a look-up table on the first byte
that would direct you to "some code"
if the first byte dictates, "some code" would do it again on another table with the second byte

Tedd

Quote from: SoraK05 on August 20, 2014, 04:46:20 AM
There is actually something very specific at the moment I'd like to optimize and I know how to do this in c++ but not in ASM.
It is to check specific bits like 'if first bit is 0', then 'if second bit is 1' for example instead of reading an entire byte to confirm contents and spare some steps by looking only at specific bit branches.

I have the general information and ASM instructions, but not sure how to check specific bit branches instead of the whole byte with ASM.
It shouldn't vary too much from x86 and any suggestion is appreciated on how to look at specific bits for a branch and proceed for specific instructions instead of an entire byte (for example if all instructions being checked only start with '0' bit instead of checking an entire 8 bit string for the instruction I am looking at and sparing 7 bit steps worth all round at the core on many instruction checks a second).

Right now a whole register content is checked to confirm a specific instruction when read and I would rather check specific bits suiting what I am checking than read the whole content.
Be sensible and use a hash/lookup table.
Potato2