Future-proof ADDR_INVALID checks by using strict [in]equality

This commit is contained in:
Jeff Parsons 2015-05-14 13:11:46 -07:00 committed by jeffpar
commit c431e5dde8
3 changed files with 10 additions and 11 deletions

View file

@ -1216,7 +1216,7 @@ X86.fnINT = function INT(nIDT, nError, nCycles)
var oldCS = this.getCS();
var oldIP = this.getIP();
var addr = this.segCS.loadIDT(nIDT);
if (addr != X86.ADDR_INVALID) {
if (addr !== X86.ADDR_INVALID) {
this.regLIP = addr;
if (PREFETCH) this.flushPrefetch(this.regLIP);
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
* 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)) {
this.setZF();
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;
* 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);
if ((fConforming || this.segVER.dpl >= this.segCS.cpl) && this.segVER.dpl >= (src & X86.SEL.RPL)) {
this.setZF();
@ -1643,7 +1643,7 @@ X86.fnLSS = function LSS(dst, src)
X86.fnLTR = function LTR(dst, src)
{
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.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.
*/
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,
* 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.
*/
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
*/