V86 handler?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
SystemHalted

V86 handler?

Post by SystemHalted »

How do I write a V86 Handler? Any info is greaty appriciated.
Jamethiel

RE:V86 handler?

Post by Jamethiel »

The basics are fairly well laid out in the manual (any manual from the 386 on up), but I'll give a quick overview anyway.

Set up a TSS, blah blah, paging, blah blah, low 1meg of memory set up for your v86 process, etc. Usual deal.

Add a special GPF handler for when the v86 task hits an IOPL-sensetive instruction. You will need to write emulation code for the instructions that you want the v86 task to be able to execute (pushf and popf come to mind, for example).

If you are going to use an invalid opcode to signal a return from v86 mode (if you're just doing callout to v86 code rather than a machine emulator, for example), install an invalid opcode handler to check for that particular opcode. Another way to trigger a return would be to check for an OUT or IN instruction from a specific port or something equally inane for normal code.

Also, the return frame for a v86 mode task includes the segment register values as well as the normal ss/sp/cs/ip/flags. Just set the vm86 bit in the flags on the stack before doing the return to ring3 to enter vm86 mode.

That's the basics. As I said, the manuals cover the details.

Hope this helps.

--Jamethiel
Post Reply