Fixed FLAG bit emulation for improved 80286/80386 compatibility
This commit is contained in:
parent
2a7bc0f454
commit
f9fa88b3c5
1 changed files with 13 additions and 1 deletions
|
|
@ -1604,6 +1604,18 @@ X86CPU.prototype.setPS = function(regPS)
|
|||
if (regPS & X86.PS.SF) this.setSF();
|
||||
if (regPS & X86.PS.OF) this.setOF();
|
||||
|
||||
/*
|
||||
* OS/2 1.0 discriminates between an 80286 and an 80386 based on whether an IRET in real-mode that
|
||||
* pops 0xF000 into the flags is able to set *any* of flag bits 12-15: if yes, then OS/2 declares the
|
||||
* the CPU an 80386. Therefore, in real-mode, we must effectively zero all incoming bits 12-15.
|
||||
*
|
||||
* This has the added benefit of relieving us from zeroing the effective IOPL (this.nIOPL) in real-mode,
|
||||
* since we're zeroing the IOPL bits up front; so that code below is commented out now.
|
||||
*/
|
||||
if (!(this.regMSW & X86.MSW.PE)) {
|
||||
regPS &= ~(X86.PS.IOPL.MASK | X86.PS.NT | X86.PS.BIT15);
|
||||
}
|
||||
|
||||
/*
|
||||
* Since PS.IOPL and PS.IF are part of PS_DIRECT, we need to take care of any 80286-specific checks before
|
||||
* setting the PS_DIRECT bits from the incoming regPS bits. Specifically, PS.IOPL is unchanged if CPL > 0,
|
||||
|
|
@ -1611,7 +1623,7 @@ X86CPU.prototype.setPS = function(regPS)
|
|||
*/
|
||||
if (!this.segCS.cpl) {
|
||||
this.nIOPL = (regPS & X86.PS.IOPL.MASK) >> X86.PS.IOPL.SHIFT; // IOPL allowed to change
|
||||
if (this.nIOPL && !(this.regMSW & X86.MSW.PE)) this.nIOPL = 0; // effective IOPL remains 0
|
||||
// if (this.nIOPL && !(this.regMSW & X86.MSW.PE)) this.nIOPL = 0; // effective IOPL remains 0
|
||||
} else {
|
||||
regPS = (regPS & ~X86.PS.IOPL.MASK) | (this.regPS & X86.PS.IOPL.MASK); // IOPL not allowed to change
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue