Virtual 8086 stack with interrupt handlers
Posted: Fri Jan 17, 2025 2:51 pm
I have decided to implement v86 mode into the kernel I have been writing.
I've been looking at how to do this, and something has been bugging me.
Suppose that the CPU is executing in v86 mode and hits an INT instruction/a hardware interrupt occurs.
When in v86 mode the stack is at SS:SP as in SS * 4 + SP.
In the interrupt handler the stack is at a totally different location based on the same SS:SP registers.
Is this right? Am I supposed to check whether the CPU was just executing v86 code and if it was flatten the stack address and fix the stack segment register?
(I'm not using paging/Don't know if that would matter here)
I've been looking at how to do this, and something has been bugging me.
Suppose that the CPU is executing in v86 mode and hits an INT instruction/a hardware interrupt occurs.
When in v86 mode the stack is at SS:SP as in SS * 4 + SP.
In the interrupt handler the stack is at a totally different location based on the same SS:SP registers.
Is this right? Am I supposed to check whether the CPU was just executing v86 code and if it was flatten the stack address and fix the stack segment register?
(I'm not using paging/Don't know if that would matter here)