VOGONS


First post, by superfury

User metadata
Rank l33t++
Rank
l33t++

Does the opcode map itself contain any errors? Afaik I have the mapping according to appendix A(on the 80386 cpu emulation), protected mode mechanics(according to the pm and multitasking chapters) and opcode handlers (according to the instruction set chapters) themselves all implemented as documented. But various software, including windows versions other than 3.x(although including 3.0 in 386 enhanced mode only as not working/crashing to MS-DOS prompt, 3.1(1) and WfW 3.1(1) all run without problems) and linux kernel 0.99(the first slackware, using linux 0.99pl14 kernel afaik) all crash with bsod(windows 95), kernel panic(linux versions) or please run setup again(due to hardware mismatch(not literally, but that's the gist of it) it says) on NT 3.1. NT4 and up BSOD always after loading disk 2 or 3.

Anyone knows of any errors or missing documentation within the 80386 programmer's reference manual?

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

Reply 1 of 4, by superfury

User metadata
Rank l33t++
Rank
l33t++

Just found a few more little bugs in my emulation, reading the 80386 programmer's reference manual's instruction set chapters:
- LDTR faults during task switching were throwing #GP(TS) instead of #FS(TS)
- LEAVE was checking the top of the stack against segmentation+paging, while it should check the SS:(E)BP address instead. Thus any protection for said addresses would fail, as well as the paging unit possibly miscalculating the TLB entry for the access(perhaps even faulting when it wasn't supposed to, when a TLB miss and page fault occurs because of it).

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

Reply 2 of 4, by superfury

User metadata
Rank l33t++
Rank
l33t++

Hmmm... Some of the stack instruction mentions some strange things. They either say #SS(0) when stack is out of bounds, before(all cases in UniPCemu), after(only with ENTER in UniPCemu. Also, why?) or before and after(also only with ENTER in UniPCemu. Also, why after?) the instruction? Anyone knows what that means?

Why would you check for invalid ESP after an instruction?

Enter:

#SS(0) if SP or ESP would exceed the stack limit at any point during instruction execution

Is that also when the instruction has pushed all it needs to push, before the next instruction?

Leave:

#SS(0) if BP does not point to a location within the limits of the current stack segment

Makes sense?

Pop:

#SS(0) if the current top of stack is not within the stack segment

What is "the current top of stack"?

Popa:

#SS(0) if the starting or ending stack address is not within the stack segment

Huh? Ending stack address? After the instruction completes? What about everything in between?

Popf:

#SS(0) if the top of stack is not within the stack segment

Again, what is "top of stack"? When is that checked(before, during, after?)?

Push:

#SS(0) if the new value of SP or ESP is outside the stack segment limit

Does that mean after the instruction finishes it's push?

Pusha:

#SS(0) if the starting or ending stack address is outside the stack segment limit

Again, see Popa.

Pushf:

#SS(0) if the new value of eSP is outside the stack segment boundaries

Is that another post-instruction check? After eSP is decremented and it's address written to?

Anyone?

It seems like it #SS(0) faults when some of those pushes reach the bottom of the stack for any possible push to the limit of the stack being reached because of an extra simulated push(without paging check) after those?

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

Reply 3 of 4, by Jo22

User metadata
Rank l33t++
Rank
l33t++

Sorry, can't help on/with this. 🙁
However, perhaps can other documents from AMD or Cyrix be helpful.
Or if whenever it's non-386 specific, check an older Intel document (say iAPX 286).
Modern Intel documents tend to confuse al lot of legacy stuff.

"Time, it seems, doesn't flow. For some it's fast, for some it's slow.
In what to one race is no time at all, another race can rise and fall..." - The Minstrel

//My video channel//

Reply 4 of 4, by superfury

User metadata
Rank l33t++
Rank
l33t++

I have one little question, though.

With ENTER, the final (e)sp value is checked for validity(only segmentation, not paging), according to https://www.felixcloutier.com/x86/enter .
What kind of access is this? Is it a byte, word or dword access? Or is it the same as the operand size(16-bits or 32-bits)? UniPCemu currently checks against a byte memory access at (E)SP.

Edit: The iapx 286 manual seems to not mention the cases quoted in my previous post at all, except for the local (dynamic) variables of the enter instruction?

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