Quote:
This is clever, but probably too clever.
As nullplan said, it's probably better to have your own code that runs in v86 mode for your protected mode code to transfer control to on entering v86 mode, and to have that code call the BIOS routine. When the BIOS routine finishes, your trampoline code can then trap back to protected mode by a method that's under your control, and thus guaranteed to actually trap.
I agree, I was just looking for a way that minimised the amount of assembly I had to write. And ultimately, if you think about it, it's sort of what I'm doing anyway: I am manually creating a real mode stack frame that looks exactly as if I had issued an int instruction in real mode.
However, thinking about it some more, it is probably a good idea to dedicate an interrupt to exiting v8086, instead of checking for stack underflow like I'm doing. I suppose some BIOS routine could (on purpose or not) mess around with the stack temporarily, and if they happen to issue an iret while the stack has been moved somewhere else, the v8086 manager could mistake that for underflow. Using a dedicated interrupt would solve that.
I'm still digesting MichaelPetch's suggestion.
Thanks for the input!