More FPU work

This commit is contained in:
Jeff Parsons 2015-11-16 17:41:55 -08:00
commit d9e280f279
4 changed files with 638 additions and 180 deletions

View file

@ -432,7 +432,7 @@ if (DEBUGGER) {
"FINCSTP","FDECSTP","FFREE", "FNOP", "FWAIT"
];
Debugger.FPU_TAGS = ["VALID", "ZERO", "SPECIAL", "EMPTY"];
Debugger.FPU_TAGS = ["VALID", "ZERO ", "SPEC ", "EMPTY"];
Debugger.CPU_8086 = 0;
Debugger.CPU_80186 = 1;
@ -554,10 +554,10 @@ if (DEBUGGER) {
Debugger.TYPE_SR = 0x000B; // FPU SR (short-real; 32-bit)
Debugger.TYPE_LI = 0x000C; // FPU LI (long-integer; 64-bit)
Debugger.TYPE_LR = 0x000C; // FPU LR (long-real; 64-bit)
Debugger.TYPE_TR = 0x000D; // FPU TR (temp-real; 80-zbit)
Debugger.TYPE_PD = 0x000D; // FPU PD (packed-decimal, 18 digits; 80-bit)
Debugger.TYPE_ENV = 0x000E; // FPU ENV (environment; 14 bytes)
Debugger.TYPE_FPU = 0x000F; // FPU SAVE (save/restore; 94 bytes)
Debugger.TYPE_TR = 0x000D; // FPU TR (temp-real; 80-bit)
Debugger.TYPE_PD = 0x000E; // FPU PD (packed-decimal, 18 digits; 80-bit)
Debugger.TYPE_ENV = 0x000F; // FPU ENV (environment; 14 bytes in real-mode, 28 bytes in protected-mode)
Debugger.TYPE_FPU = 0x000F; // FPU SAVE (save/restore; 94 bytes in real-mode, 108 bytes in protected-mode)
/*
* TYPE_MODE values. Order is somewhat important, as all values implying
@ -5121,6 +5121,20 @@ if (DEBUGGER) {
case Debugger.TYPE_LONG:
sPrefix = "DWORD";
break;
case Debugger.TYPE_SI:
case Debugger.TYPE_SR:
sPrefix = "SREAL";
break;
case Debugger.TYPE_LI:
case Debugger.TYPE_LR:
sPrefix = "LREAL";
break;
case Debugger.TYPE_TR:
sPrefix = "TREAL";
break;
case Debugger.TYPE_PD:
sPrefix = "DEC18";
break;
}
if (sPrefix) sOperand = sPrefix + ' ' + sOperand;
}
@ -7289,14 +7303,18 @@ if (DEBUGGER) {
*/
Debugger.prototype.doFPURegisters = function(asArgs)
{
this.assert(this.fpu);
var fpu = this.fpu;
this.assert(fpu);
var wStatus = fpu.getStatus(), wControl = fpu.getControl();
for (var i = 0; i < 8; i++) {
var a = this.fpu.readFPUStack(i);
var a = fpu.readFPUStack(i);
if (!a) break;
var sValue = str.pad(a[2].toFixed(15), 24, true);
this.println("ST" + i + ": " + sValue + " " + str.toHex(a[4]) + "," + str.toHex(a[3]) + " [" + Debugger.FPU_TAGS[a[1]] + "]");
this.println("ST" + i + ": " + sValue + " " + str.toHex(a[4]) + "," + str.toHex(a[3]) + " [" + a[0] + ":" + Debugger.FPU_TAGS[a[1]] + "]");
// this.println(" REG" + a[0] + " " + str.toBin(a[7], 16) + str.toBin(a[6]) + str.toBin(a[5]));
}
this.println(" B3SSS210ESPUOZDI xxxIRRPPIxPUOZDI");
this.println("SW: " + str.toBin(wStatus, 16) + " (" + str.toHexWord(wStatus) + ") CW: " + str.toBin(wControl, 16) + " (" + str.toHexWord(wControl) + ")");
};
/**

View file

@ -552,12 +552,13 @@ var X86 = {
PE: 0x0020, // bit 5: Precision
SF: 0x0040, // bit 6: Stack Fault (80387 and later)
EXC: 0x007F, // all of the above exceptions
ES: 0x0080, // bit 7: Exception Summary (Interrupt Request on 8087)
ES: 0x0080, // bit 7: Error/Exception Status/Summary (Interrupt Request on 8087)
C0: 0x0100, // bit 8: Condition Code 0
C1: 0x0200, // bit 9: Condition Code 1
C2: 0x0400, // bit 10: Condition Code 2
ST: 0x3800, // bits 11-13: Stack Top
C3: 0x4000, // bit 14: Condition Code 3
CC: 0x4700, // all condition code bits
BUSY: 0x8000, // bit 15: Busy
ST_SHIFT: 11
},

File diff suppressed because it is too large Load diff

View file

@ -1097,6 +1097,52 @@ X86.opPUSHBX = function()
/**
* op=0x54 (PUSH SP)
*
* NOTE: Having an accurate implementation of "PUSH SP" for the 8086/8088 isn't just a nice idea, it affects real
* code. Case in point: early Microsoft C floating-point libraries relied on "PUSH SP" behavior to quickly determine
* whether an 8088 (and therefore presumably an 8087) or an 80286 (and presumably an 80287) was being used; eg:
*
* &0910:1E82 D93E1709 FSTCW WORD [0917]
* &0910:1E86 CD3D INT 3D
* &0E4E:06D3 50 PUSH AX
* &0E4E:06D4 B83DA2 MOV AX,A23D
* &0E4E:06D7 EB04 JMP 06DD
* &0E4E:06DD 55 PUSH BP
* &0E4E:06DE 1E PUSH DS
* &0E4E:06DF 56 PUSH SI
* &0E4E:06E0 8BEC MOV BP,SP
* &0E4E:06E2 C57608 LDS SI,[BP+08]
* &0E4E:06E5 4E DEC SI
* &0E4E:06E6 4E DEC SI
* &0E4E:06E7 897608 MOV [BP+08],SI
* &0E4E:06EA 2904 SUB [SI],AX
* &0E4E:06EC 53 PUSH BX
* &0E4E:06ED 33DB XOR BX,BX
* &0E4E:06EF 54 PUSH SP ; beginning of processor check
* &0E4E:06F0 58 POP AX
* &0E4E:06F1 3BC4 CMP AX,SP
* &0E4E:06F3 7528 JNZ 071D ; jump if 8086/8088/80186/80188, no jump if 80286 or later
* &0E4E:06F5 8B4001 MOV AX,[BX+SI+01]
* &0E4E:06F8 25FB30 AND AX,30FB
* &0E4E:06FB 3DD930 CMP AX,30D9
* &0E4E:06FE 7507 JNZ 0707
* &0E4E:0700 8A4002 MOV AL,[BX+SI+02]
* &0E4E:0703 3CF0 CMP AL,F0
* &0E4E:0705 7216 JC 071D
* &0E4E:0707 8B4001 MOV AX,[BX+SI+01]
* &0E4E:070A 25FFFE AND AX,FEFF
* &0E4E:070D 3DDBE2 CMP AX,E2DB
* &0E4E:0710 740B JZ 071D
* &0E4E:0712 8B4001 MOV AX,[BX+SI+01]
* &0E4E:0715 3DDFE0 CMP AX,E0DF
* &0E4E:0718 7403 JZ 071D
* &0E4E:071A C60490 MOV [SI],90
* &0E4E:071D 5B POP BX
* &0E4E:071E 5E POP SI
* &0E4E:071F 1F POP DS
* &0E4E:0720 5D POP BP
* &0E4E:0721 58 POP AX
* &0E4E:0722 CF IRET
*
* @this {X86CPU}
*/
X86.opPUSHSP_8086 = function()