Fix Debugger register lookup for 80286/80386
This commit is contained in:
parent
dd12198e62
commit
56d03451ac
2 changed files with 86 additions and 56 deletions
|
|
@ -2052,50 +2052,57 @@ if (DEBUGGER) {
|
||||||
n = cpu.getDS(); cch = 4;
|
n = cpu.getDS(); cch = 4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (I386 && this.cpu.model >= X86.MODEL_80386 && !cch) {
|
if (!cch) {
|
||||||
switch(iReg) {
|
if (this.cpu.model == X86.MODEL_80286) {
|
||||||
case Debugger.REG_EAX:
|
if (iReg == Debugger.REG_CR0) {
|
||||||
n = cpu.regEAX; cch = 8;
|
n = cpu.regCR0; cch = 4;
|
||||||
break;
|
}
|
||||||
case Debugger.REG_ECX:
|
}
|
||||||
n = cpu.regECX; cch = 8;
|
else if (I386 && this.cpu.model >= X86.MODEL_80386) {
|
||||||
break;
|
switch(iReg) {
|
||||||
case Debugger.REG_EDX:
|
case Debugger.REG_EAX:
|
||||||
n = cpu.regEDX; cch = 8;
|
n = cpu.regEAX; cch = 8;
|
||||||
break;
|
break;
|
||||||
case Debugger.REG_EBX:
|
case Debugger.REG_ECX:
|
||||||
n = cpu.regEBX; cch = 8;
|
n = cpu.regECX; cch = 8;
|
||||||
break;
|
break;
|
||||||
case Debugger.REG_ESP:
|
case Debugger.REG_EDX:
|
||||||
n = cpu.getSP(); cch = 8;
|
n = cpu.regEDX; cch = 8;
|
||||||
break;
|
break;
|
||||||
case Debugger.REG_EBP:
|
case Debugger.REG_EBX:
|
||||||
n = cpu.regEBP; cch = 8;
|
n = cpu.regEBX; cch = 8;
|
||||||
break;
|
break;
|
||||||
case Debugger.REG_ESI:
|
case Debugger.REG_ESP:
|
||||||
n = cpu.regESI; cch = 8;
|
n = cpu.getSP(); cch = 8;
|
||||||
break;
|
break;
|
||||||
case Debugger.REG_EDI:
|
case Debugger.REG_EBP:
|
||||||
n = cpu.regEDI; cch = 8;
|
n = cpu.regEBP; cch = 8;
|
||||||
break;
|
break;
|
||||||
case Debugger.REG_CR0:
|
case Debugger.REG_ESI:
|
||||||
n = cpu.regCR0; cch = 8;
|
n = cpu.regESI; cch = 8;
|
||||||
break;
|
break;
|
||||||
case Debugger.REG_CR1:
|
case Debugger.REG_EDI:
|
||||||
n = cpu.regCR1; cch = 8;
|
n = cpu.regEDI; cch = 8;
|
||||||
break;
|
break;
|
||||||
case Debugger.REG_CR2:
|
case Debugger.REG_CR0:
|
||||||
n = cpu.regCR2; cch = 8;
|
n = cpu.regCR0; cch = 8;
|
||||||
break;
|
break;
|
||||||
case Debugger.REG_CR3:
|
case Debugger.REG_CR1:
|
||||||
n = cpu.regCR3; cch = 8;
|
n = cpu.regCR1; cch = 8;
|
||||||
break;
|
break;
|
||||||
case Debugger.REG_SEG + Debugger.REG_FS:
|
case Debugger.REG_CR2:
|
||||||
n = cpu.getFS(); cch = 4;
|
n = cpu.regCR2; cch = 8;
|
||||||
break;
|
break;
|
||||||
case Debugger.REG_SEG + Debugger.REG_GS:
|
case Debugger.REG_CR3:
|
||||||
n = cpu.getGS(); cch = 4;
|
n = cpu.regCR3; cch = 8;
|
||||||
break;
|
break;
|
||||||
|
case Debugger.REG_SEG + Debugger.REG_FS:
|
||||||
|
n = cpu.getFS(); cch = 4;
|
||||||
|
break;
|
||||||
|
case Debugger.REG_SEG + Debugger.REG_GS:
|
||||||
|
n = cpu.getGS(); cch = 4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cch) s = str.toHex(n, cch);
|
if (cch) s = str.toHex(n, cch);
|
||||||
|
|
@ -3476,7 +3483,9 @@ if (DEBUGGER) {
|
||||||
Debugger.prototype.getRegString = function(iReg)
|
Debugger.prototype.getRegString = function(iReg)
|
||||||
{
|
{
|
||||||
if (iReg >= Debugger.REG_AX && iReg <= Debugger.REG_DI && this.cchReg > 4) iReg += Debugger.REG_EAX - Debugger.REG_AX;
|
if (iReg >= Debugger.REG_AX && iReg <= Debugger.REG_DI && this.cchReg > 4) iReg += Debugger.REG_EAX - Debugger.REG_AX;
|
||||||
return Debugger.REGS[iReg] + '=' + this.getRegValue(iReg) + ' ';
|
var sReg = Debugger.REGS[iReg];
|
||||||
|
if (iReg == Debugger.REG_CR0 && this.cpu.model == X86.MODEL_80286) sReg = "MS";
|
||||||
|
return sReg + '=' + this.getRegValue(iReg) + ' ';
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -4801,8 +4810,10 @@ if (DEBUGGER) {
|
||||||
this.println("missing value for " + asArgs[1]);
|
this.println("missing value for " + asArgs[1]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var fValid = false;
|
||||||
var w = str.parseInt(sValue, 16);
|
var w = str.parseInt(sValue, 16);
|
||||||
if (!isNaN(w)) {
|
if (!isNaN(w)) {
|
||||||
|
fValid = true;
|
||||||
var sRegMatch = sReg.toUpperCase();
|
var sRegMatch = sReg.toUpperCase();
|
||||||
if (sRegMatch.charAt(0) == 'E' && this.cchReg <= 4) {
|
if (sRegMatch.charAt(0) == 'E' && this.cchReg <= 4) {
|
||||||
sRegMatch = null;
|
sRegMatch = null;
|
||||||
|
|
@ -4916,7 +4927,9 @@ if (DEBUGGER) {
|
||||||
this.cpu.setMSW(w);
|
this.cpu.setMSW(w);
|
||||||
break;
|
break;
|
||||||
case "TR":
|
case "TR":
|
||||||
this.cpu.segTSS.load(w, true);
|
if (this.cpu.segTSS.load(w, true) === X86.ADDR_INVALID) {
|
||||||
|
fValid = false;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
* TODO: Add support for GDTR (addr and limit), IDTR (addr and limit), and perhaps
|
* TODO: Add support for GDTR (addr and limit), IDTR (addr and limit), and perhaps
|
||||||
|
|
@ -4957,8 +4970,17 @@ if (DEBUGGER) {
|
||||||
case "GS":
|
case "GS":
|
||||||
this.cpu.setGS(w);
|
this.cpu.setGS(w);
|
||||||
break;
|
break;
|
||||||
|
case "CR0":
|
||||||
|
this.cpu.regCR0 = w;
|
||||||
|
break;
|
||||||
|
case "CR2":
|
||||||
|
this.cpu.regCR2 = w;
|
||||||
|
break;
|
||||||
|
case "CR3":
|
||||||
|
this.cpu.regCR3 = w;
|
||||||
|
break;
|
||||||
/*
|
/*
|
||||||
* TODO: Add support for CR0-CR3, DR0-DR7, and TR6-TR7.
|
* TODO: Add support for DR0-DR7 and TR6-TR7.
|
||||||
*/
|
*/
|
||||||
default:
|
default:
|
||||||
fUnknown = true;
|
fUnknown = true;
|
||||||
|
|
@ -4974,7 +4996,7 @@ if (DEBUGGER) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
if (!fValid) {
|
||||||
this.println("invalid value: " + sValue);
|
this.println("invalid value: " + sValue);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -339,7 +339,7 @@ toProt32:
|
||||||
;
|
;
|
||||||
; Test moving a segment register to a 32-bit memory location
|
; Test moving a segment register to a 32-bit memory location
|
||||||
;
|
;
|
||||||
test1: mov edx,[0x0000] ; save the DWORD at 0x0000:0x0000 in EDX
|
mov edx,[0x0000] ; save the DWORD at 0x0000:0x0000 in EDX
|
||||||
or eax,-1
|
or eax,-1
|
||||||
mov [0x0000],eax
|
mov [0x0000],eax
|
||||||
mov [0x0000],ds
|
mov [0x0000],ds
|
||||||
|
|
@ -351,29 +351,37 @@ test1: mov edx,[0x0000] ; save the DWORD at 0x0000:0x0000 in EDX
|
||||||
cmp eax,[0x0000]
|
cmp eax,[0x0000]
|
||||||
jne near error
|
jne near error
|
||||||
mov [0x0000],edx ; restore the DWORD at 0x0000:0x0000 from EDX
|
mov [0x0000],edx ; restore the DWORD at 0x0000:0x0000 from EDX
|
||||||
jmp test2
|
jmp testROM
|
||||||
|
|
||||||
|
;
|
||||||
|
; The next few tests currently work only when running as a ROM image; they rely not only on
|
||||||
|
; the contents of the last two bytes at the top of the first 1Mb, but also on their location,
|
||||||
|
; because if the processor improperly reads beyond those bytes, a fault should occur.
|
||||||
|
;
|
||||||
|
testROM:
|
||||||
|
|
||||||
;
|
;
|
||||||
; Test moving a byte to a 32-bit register with sign-extension
|
; Test moving a byte to a 32-bit register with sign-extension
|
||||||
;
|
;
|
||||||
test2: movsx eax,byte [0xfffff]
|
movsx eax,byte [0xfffff]
|
||||||
cmp eax,0xffffff80
|
cmp eax,0xffffff80
|
||||||
jne error
|
jne error
|
||||||
;
|
;
|
||||||
; Test moving a word to a 32-bit register with sign-extension
|
; Test moving a word to a 32-bit register with sign-extension
|
||||||
;
|
;
|
||||||
test3: movsx eax,word [0xffffe]
|
movsx eax,word [0xffffe]
|
||||||
cmp eax,0xffff80fc
|
cmp eax,0xffff80fc
|
||||||
jne error
|
jne error
|
||||||
;
|
;
|
||||||
; Test moving a byte to a 32-bit register with zero-extension
|
; Test moving a byte to a 32-bit register with zero-extension
|
||||||
;
|
;
|
||||||
test4: movzx eax,byte [0xfffff]
|
movzx eax,byte [0xfffff]
|
||||||
cmp eax,0x00000080
|
cmp eax,0x00000080
|
||||||
jne error
|
jne error
|
||||||
;
|
;
|
||||||
; Test moving a word to a 32-bit register with zero-extension
|
; Test moving a word to a 32-bit register with zero-extension
|
||||||
;
|
;
|
||||||
test5: movzx eax,word [0xffffe]
|
movzx eax,word [0xffffe]
|
||||||
cmp eax,0x000080fc
|
cmp eax,0x000080fc
|
||||||
jne error
|
jne error
|
||||||
jmp doneProt
|
jmp doneProt
|
||||||
|
|
@ -401,11 +409,11 @@ jmpReal:
|
||||||
jmp CSEG_REAL:toReal
|
jmp CSEG_REAL:toReal
|
||||||
|
|
||||||
toReal:
|
toReal:
|
||||||
mov ax,cs
|
mov ax,cs ; revert to the usual .COM register conventions
|
||||||
mov ds,ax
|
mov ds,ax
|
||||||
mov es,ax
|
mov es,ax
|
||||||
mov ss,ax
|
mov ss,ax
|
||||||
sub sp,sp
|
mov sp,0xfffe
|
||||||
|
|
||||||
cmp ax,CSEG_REAL ; is CS equal to 0xf000?
|
cmp ax,CSEG_REAL ; is CS equal to 0xf000?
|
||||||
je near jmpStart ; yes, so loop around, only because we have nowhere else to go
|
je near jmpStart ; yes, so loop around, only because we have nowhere else to go
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue