diff --git a/modules/pcjs/lib/x86cpu.js b/modules/pcjs/lib/x86cpu.js index 5d574bf0e..778571ad8 100644 --- a/modules/pcjs/lib/x86cpu.js +++ b/modules/pcjs/lib/x86cpu.js @@ -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 }