VOGONS


First post, by superfury

User metadata
Rank l33t++
Rank
l33t++

When the ENTER instruction on a 80286-80486 CPU raises an exception while either pushing the (E)BP at the start or during pushing the word/doubleword BP values(nestinglevel>0) and or during the following FrameTemp push at the bottom, how does the OS recover the process from this, when a page fault etc. occurs during the operations? BP can't be relied on(since it's partially/not decreased) and SP can't be relied on(since SP can be anything)?

Anyone? Jepael?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 1 of 2, by SarahWalker

User metadata
Rank Member
Rank
Member

BP and SP will be restored to the values they had at the start of the instruction before the exception handler is entered. This is basically the case for all registers when any instruction causes an exception/fault.

Reply 2 of 2, by superfury

User metadata
Rank l33t++
Rank
l33t++

OK. I've modified the CPU code to save SP for restoring it when an exception occurs, while BP is buffered instead of decreased(it's used only during execution, when processing the nesting level 1-X). So instead of decreasing BP(changing the register) and using it as a memory address to read, it now directly applies the address by taking BP-(nestinglevel<<1), leaving BP unaffected(since it's overwritten by the end of the function anyways, when succeeding and not used anywhere else further down the procedure).

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io