Future-proof ADDR_INVALID checks by using strict [in]equality
This commit is contained in:
parent
56d03451ac
commit
c431e5dde8
3 changed files with 10 additions and 11 deletions
|
|
@ -410,9 +410,8 @@ if (DEBUGGER) {
|
||||||
Debugger.TYPE_OTHER = 0xF000; // "other" field
|
Debugger.TYPE_OTHER = 0xF000; // "other" field
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TYPE_SIZE values. Note that some of the values (eg, TYPE_WORDIB
|
* TYPE_SIZE values. Some of the values (eg, TYPE_WORDIB and TYPE_WORDIW)
|
||||||
* and TYPE_WORDIW) imply the presence of a third operand, for those
|
* imply the presence of a third operand, for those weird cases....
|
||||||
* weird cases....
|
|
||||||
*/
|
*/
|
||||||
Debugger.TYPE_NONE = 0x0000; // (all other TYPE fields ignored)
|
Debugger.TYPE_NONE = 0x0000; // (all other TYPE fields ignored)
|
||||||
Debugger.TYPE_BYTE = 0x0001; // (b) byte, regardless of operand size
|
Debugger.TYPE_BYTE = 0x0001; // (b) byte, regardless of operand size
|
||||||
|
|
@ -428,7 +427,7 @@ if (DEBUGGER) {
|
||||||
Debugger.TYPE_PREFIX = 0x000F; // (treat similarly to TYPE_NONE)
|
Debugger.TYPE_PREFIX = 0x000F; // (treat similarly to TYPE_NONE)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TYPE_MODE values. Note that order is somewhat important, as all values implying
|
* TYPE_MODE values. Order is somewhat important, as all values implying
|
||||||
* the presence of a ModRM byte are assumed to be >= TYPE_MODRM.
|
* the presence of a ModRM byte are assumed to be >= TYPE_MODRM.
|
||||||
*/
|
*/
|
||||||
Debugger.TYPE_IMM = 0x0000; // (I) immediate data
|
Debugger.TYPE_IMM = 0x0000; // (I) immediate data
|
||||||
|
|
|
||||||
|
|
@ -1216,7 +1216,7 @@ X86.fnINT = function INT(nIDT, nError, nCycles)
|
||||||
var oldCS = this.getCS();
|
var oldCS = this.getCS();
|
||||||
var oldIP = this.getIP();
|
var oldIP = this.getIP();
|
||||||
var addr = this.segCS.loadIDT(nIDT);
|
var addr = this.segCS.loadIDT(nIDT);
|
||||||
if (addr != X86.ADDR_INVALID) {
|
if (addr !== X86.ADDR_INVALID) {
|
||||||
this.regLIP = addr;
|
this.regLIP = addr;
|
||||||
if (PREFETCH) this.flushPrefetch(this.regLIP);
|
if (PREFETCH) this.flushPrefetch(this.regLIP);
|
||||||
this.pushWord(oldPS);
|
this.pushWord(oldPS);
|
||||||
|
|
@ -1311,7 +1311,7 @@ X86.fnLAR = function LAR(dst, src)
|
||||||
* TODO: This instruction's 80286 documentation does not discuss conforming code segments; determine
|
* TODO: This instruction's 80286 documentation does not discuss conforming code segments; determine
|
||||||
* if we need a special check for them.
|
* if we need a special check for them.
|
||||||
*/
|
*/
|
||||||
if (this.segVER.load(src, true) != X86.ADDR_INVALID) {
|
if (this.segVER.load(src, true) !== X86.ADDR_INVALID) {
|
||||||
if (this.segVER.dpl >= this.segCS.cpl && this.segVER.dpl >= (src & X86.SEL.RPL)) {
|
if (this.segVER.dpl >= this.segCS.cpl && this.segVER.dpl >= (src & X86.SEL.RPL)) {
|
||||||
this.setZF();
|
this.setZF();
|
||||||
return this.segVER.acc & X86.DESC.ACC.MASK;
|
return this.segVER.acc & X86.DESC.ACC.MASK;
|
||||||
|
|
@ -1600,7 +1600,7 @@ X86.fnLSL = function LSL(dst, src)
|
||||||
* TODO: LSL is explicitly documented as ALSO requiring a non-null selector, so we check X86.SEL.MASK;
|
* TODO: LSL is explicitly documented as ALSO requiring a non-null selector, so we check X86.SEL.MASK;
|
||||||
* are there any other instructions that were, um, less explicit but also require a non-null selector?
|
* are there any other instructions that were, um, less explicit but also require a non-null selector?
|
||||||
*/
|
*/
|
||||||
if ((src & X86.SEL.MASK) && this.segVER.load(src, true) != X86.ADDR_INVALID) {
|
if ((src & X86.SEL.MASK) && this.segVER.load(src, true) !== X86.ADDR_INVALID) {
|
||||||
var fConforming = ((this.segVER.acc & X86.DESC.ACC.TYPE.CODE_CONFORMING) == X86.DESC.ACC.TYPE.CODE_CONFORMING);
|
var fConforming = ((this.segVER.acc & X86.DESC.ACC.TYPE.CODE_CONFORMING) == X86.DESC.ACC.TYPE.CODE_CONFORMING);
|
||||||
if ((fConforming || this.segVER.dpl >= this.segCS.cpl) && this.segVER.dpl >= (src & X86.SEL.RPL)) {
|
if ((fConforming || this.segVER.dpl >= this.segCS.cpl) && this.segVER.dpl >= (src & X86.SEL.RPL)) {
|
||||||
this.setZF();
|
this.setZF();
|
||||||
|
|
@ -1643,7 +1643,7 @@ X86.fnLSS = function LSS(dst, src)
|
||||||
X86.fnLTR = function LTR(dst, src)
|
X86.fnLTR = function LTR(dst, src)
|
||||||
{
|
{
|
||||||
this.opFlags |= X86.OPFLAG.NOWRITE;
|
this.opFlags |= X86.OPFLAG.NOWRITE;
|
||||||
if (this.segTSS.load(dst) != X86.ADDR_INVALID) {
|
if (this.segTSS.load(dst) !== X86.ADDR_INVALID) {
|
||||||
this.setShort(this.segTSS.addrDesc + X86.DESC.ACC.OFFSET, this.segTSS.acc |= X86.DESC.ACC.TYPE.LDT);
|
this.setShort(this.segTSS.addrDesc + X86.DESC.ACC.OFFSET, this.segTSS.acc |= X86.DESC.ACC.TYPE.LDT);
|
||||||
this.segTSS.type = X86.DESC.ACC.TYPE.TSS_BUSY;
|
this.segTSS.type = X86.DESC.ACC.TYPE.TSS_BUSY;
|
||||||
}
|
}
|
||||||
|
|
@ -3237,7 +3237,7 @@ X86.fnVERR = function VERR(dst, src)
|
||||||
* descriptor table or the descriptor is not for a segment.
|
* descriptor table or the descriptor is not for a segment.
|
||||||
*/
|
*/
|
||||||
this.nStepCycles -= (14 + (this.regEA === X86.ADDR_INVALID? 0 : 2));
|
this.nStepCycles -= (14 + (this.regEA === X86.ADDR_INVALID? 0 : 2));
|
||||||
if (this.segVER.load(dst, true) != X86.ADDR_INVALID) {
|
if (this.segVER.load(dst, true) !== X86.ADDR_INVALID) {
|
||||||
/*
|
/*
|
||||||
* Verify that this is a readable segment; that is, of these four combinations (code+readable,
|
* Verify that this is a readable segment; that is, of these four combinations (code+readable,
|
||||||
* code+nonreadable, data+writable, date+nonwritable), make sure we're not the second combination.
|
* code+nonreadable, data+writable, date+nonwritable), make sure we're not the second combination.
|
||||||
|
|
@ -3279,7 +3279,7 @@ X86.fnVERW = function VERW(dst, src)
|
||||||
* descriptor table or the descriptor is not for a segment.
|
* descriptor table or the descriptor is not for a segment.
|
||||||
*/
|
*/
|
||||||
this.nStepCycles -= (14 + (this.regEA === X86.ADDR_INVALID? 0 : 2));
|
this.nStepCycles -= (14 + (this.regEA === X86.ADDR_INVALID? 0 : 2));
|
||||||
if (this.segVER.load(dst, true) != X86.ADDR_INVALID) {
|
if (this.segVER.load(dst, true) !== X86.ADDR_INVALID) {
|
||||||
/*
|
/*
|
||||||
* Verify that this is a writable data segment
|
* Verify that this is a writable data segment
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -982,7 +982,7 @@ X86Seg.prototype.updateMode = function(fLoad, fProt)
|
||||||
* hardware does not update it either. In fact, I've seen code that uses the null GDT descriptor
|
* hardware does not update it either. In fact, I've seen code that uses the null GDT descriptor
|
||||||
* for other purposes, on the assumption that that descriptor is completely unused.
|
* for other purposes, on the assumption that that descriptor is completely unused.
|
||||||
*/
|
*/
|
||||||
if ((this.sel & ~X86.SEL.RPL) && this.addrDesc != X86.ADDR_INVALID) {
|
if ((this.sel & ~X86.SEL.RPL) && this.addrDesc !== X86.ADDR_INVALID) {
|
||||||
var addrACC = this.addrDesc + X86.DESC.ACC.TYPE.OFFSET;
|
var addrACC = this.addrDesc + X86.DESC.ACC.TYPE.OFFSET;
|
||||||
this.cpu.setByte(addrACC, this.cpu.getByte(addrACC) | (X86.DESC.ACC.TYPE.ACCESSED >> 8));
|
this.cpu.setByte(addrACC, this.cpu.getByte(addrACC) | (X86.DESC.ACC.TYPE.ACCESSED >> 8));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue