Phase 1 of consolidating descriptor processing in x86seg.js (TSS descriptors are next)

This commit is contained in:
Jeff Parsons 2014-11-27 09:28:12 -08:00 • committed by jeffpar
commit 6194aac5af
4 changed files with 132 additions and 45 deletions

View file

@ -1308,7 +1308,7 @@ X86CPU.prototype.setIP = function(off)
* @param {number} off
* @param {number} sel
* @param {boolean} [fCall] is true if CALLF in progress, false if RETF in progress, null/undefined otherwise
* @return {boolean} true if a stack switch occurred; the only opcode that needs to care about this is opRETFn()
* @return {boolean|null} true if a stack switch occurred; the only opcode that really needs to care is opRETFn()
*/
X86CPU.prototype.setCSIP = function(off, sel, fCall)
{
@ -1316,13 +1316,14 @@ X86CPU.prototype.setCSIP = function(off, sel, fCall)
this.segCS.fCall = fCall;
/*
* We break this operation into the following discrete steps (eg, set IP, load CS, and then update EIP)
* so that segCS.load(sel) has the option of modifying IP when sel refers to a call gate.
* so that segCS.load(sel) has the option of modifying IP when sel refers to a gate (call, interrupt, trap, etc).
*/
this.regIP = off;
var base = this.segCS.load(sel);
if (base != null) {
this.regEIP = base + this.regIP;
if (base == null) {
return null;
}
this.regEIP = base + this.regIP;
if (PREFETCH) this.flushPrefetch(this.regEIP);
return this.segCS.fStackSwitch;
};