flat assembler
Message board for the users of flat assembler.

Index > Main > custom/emulate opcodes (using exception handler)

Author
Thread Post new topic Reply to topic
rain_storm



Joined: 05 Apr 2007
Posts: 67
Location: Ireland
rain_storm
The idea is to use the invalid opcode exception handler to emulate unsupported instructions or to implement custom opcodes. Unsupported opcodes could then be used by emulating them in software. Custom opcodes could be implemented using the ud2 opcode as a prefix, (the purpose of ud2 is to raise such exceptions).

The basic flow would be
1 execute invalid opcode (raises exception)
2 execute exception handler
3 get address of invalid opcode
4 decode the opcode
5 update the return address
6 emulate the opcode in software
7 return to modified return address

Is this possible, and if so what would be required to make it work?
Post 15 Aug 2011, 18:22
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
using fs register.
put the handler address in the first 4 bytes of FS and make sure you save it first.
In your handler get the last eip and read the bytes there and dump them.
Post 16 Aug 2011, 00:03
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
Can you tell us what the emulated instructions would do? VIA, AMD on Intel and vice versa? Maybe some really exotic instructions?
Post 16 Aug 2011, 06:11
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
rain_storm



Joined: 05 Apr 2007
Posts: 67
Location: Ireland
rain_storm
Would be nice to run some SIMD on a 386.
Post 17 Aug 2011, 03:16
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
typedef wrote:
using fs register. put the handler address in the first 4 bytes of FS and make sure


This looks Win32-specific Neutral

> Would be nice to run some SIMD on a 386.

COOL Smile (IIRC there are FPU emulators and MMX emulators out ...)
Post 17 Aug 2011, 04:05
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.