diff --git a/modules/diskdump/lib/diskdump.js b/modules/diskdump/lib/diskdump.js index a0903f0ec..650bba1ca 100644 --- a/modules/diskdump/lib/diskdump.js +++ b/modules/diskdump/lib/diskdump.js @@ -179,7 +179,7 @@ DiskDump.sNotice = DiskDump.sAPIURL + " " + DiskDump.sCopyright; DiskDump.sUsage = "Usage: " + DiskDump.sAPIURL + "?" + DumpAPI.QUERY.PATH + "={url}&" + DumpAPI.QUERY.FORMAT + "=json|data|hex|bytes|img"; /* - * MY_VOL_LABEL is our default label, used whenever a more suitable label (eg, based on the disk image's folder name) + * MY_VOL_LABEL is our default label, used whenever a more suitable label (eg, the disk image's folder name) * is not available or not supplied, and MY_OEM_STRING is inserted into any DiskDump-generated diskette images. */ DiskDump.MY_VOL_LABEL = "PCJSDISK"; @@ -192,7 +192,8 @@ DiskDump.MY_OEM_STRING = "PCJS.ORG"; DiskDump.aDefaultBPBs = [ [ // define BPB for 160Kb diskette 0xEB, 0xFE, 0x90, // 0x00: JMP instruction, following by 8-byte OEM signature - 0x49, 0x42, 0x4D, 0x20, 0x20, 0x31, 0x2E, 0x30, // "IBM 1.0" (this is a fake OEM signature) + 0x50, 0x43, 0x4A, 0x53, 0x2E, 0x4F, 0x52, 0x47, // MY_OEM_STRING + // 0x49, 0x42, 0x4D, 0x20, 0x20, 0x31, 0x2E, 0x30, // "IBM 1.0" (this is a fake OEM signature) 0x00, 0x02, // 0x0B: bytes per sector (0x200 or 512) 0x01, // 0x0D: sectors per cluster (1) 0x01, 0x00, // 0x0E: reserved sectors; ie, # sectors preceding the first FAT--usually just the boot sector (1) @@ -207,7 +208,8 @@ DiskDump.aDefaultBPBs = [ ], [ // define BPB for 360Kb diskette 0xEB, 0xFE, 0x90, // 0x00: JMP instruction, following by 8-byte OEM signature - 0x49, 0x42, 0x4D, 0x20, 0x20, 0x32, 0x2E, 0x30, // "IBM 2.0" (this is a real OEM signature) + 0x50, 0x43, 0x4A, 0x53, 0x2E, 0x4F, 0x52, 0x47, // MY_OEM_STRING + // 0x49, 0x42, 0x4D, 0x20, 0x20, 0x32, 0x2E, 0x30, // "IBM 2.0" (this is a real OEM signature) 0x00, 0x02, // 0x0B: bytes per sector (0x200 or 512) 0x02, // 0x0D: sectors per cluster (2) 0x01, 0x00, // 0x0E: reserved sectors; ie, # sectors preceding the first FAT--usually just the boot sector (1) @@ -222,7 +224,8 @@ DiskDump.aDefaultBPBs = [ ], [ // define BPB for 1.2Mb diskette 0xEB, 0xFE, 0x90, // 0x00: JMP instruction, following by 8-byte OEM signature - 0x49, 0x42, 0x4D, 0x20, 0x31, 0x30, 0x2E, 0x31, // "IBM 10.0" (which I believe was used on IBM OS/2 1.0 diskettes) + 0x50, 0x43, 0x4A, 0x53, 0x2E, 0x4F, 0x52, 0x47, // MY_OEM_STRING + // 0x49, 0x42, 0x4D, 0x20, 0x31, 0x30, 0x2E, 0x31, // "10.0" (which I believe was used on IBM OS/2 1.0 diskettes) 0x00, 0x02, // 0x0B: bytes per sector (0x200 or 512) 0x01, // 0x0D: sectors per cluster (1) 0x01, 0x00, // 0x0E: reserved sectors; ie, # sectors preceding the first FAT--usually just the boot sector (1) @@ -237,7 +240,8 @@ DiskDump.aDefaultBPBs = [ ], [ // define BPB for 1.44Mb diskette 0xEB, 0xFE, 0x90, // 0x00: JMP instruction, following by 8-byte OEM signature - 0x4d, 0x53, 0x44, 0x4F, 0x53, 0x35, 0x2E, 0x30, // "MSDOS5.0" (an actual OEM signature, arbitrarily chosen for use here) + 0x50, 0x43, 0x4A, 0x53, 0x2E, 0x4F, 0x52, 0x47, // MY_OEM_STRING + // 0x4d, 0x53, 0x44, 0x4F, 0x53, 0x35, 0x2E, 0x30, // "MSDOS5.0" (an actual OEM signature, arbitrarily chosen for use here) 0x00, 0x02, // 0x0B: bytes per sector (0x200 or 512) 0x01, // 0x0D: sectors per cluster (1) 0x01, 0x00, // 0x0E: reserved sectors; ie, # sectors preceding the first FAT--usually just the boot sector (1) @@ -252,7 +256,8 @@ DiskDump.aDefaultBPBs = [ ], [ // define BPB for 10Mb hard disk 0xEB, 0xFE, 0x90, // 0x00: JMP instruction, following by 8-byte OEM signature - 0x49, 0x42, 0x4D, 0x20, 0x20, 0x32, 0x2E, 0x30, // "IBM 2.0" (this is a real OEM signature) + 0x50, 0x43, 0x4A, 0x53, 0x2E, 0x4F, 0x52, 0x47, // MY_OEM_STRING + // 0x49, 0x42, 0x4D, 0x20, 0x20, 0x32, 0x2E, 0x30, // "IBM 2.0" (this is a real OEM signature) 0x00, 0x02, // 0x0B: bytes per sector (0x200 or 512) 0x08, // 0x0D: sectors per cluster (8) 0x01, 0x00, // 0x0E: reserved sectors; ie, # sectors preceding the first FAT--usually just the boot sector (1) diff --git a/modules/pcjs/lib/x86func.js b/modules/pcjs/lib/x86func.js index 7431ef82f..72cebce5a 100644 --- a/modules/pcjs/lib/x86func.js +++ b/modules/pcjs/lib/x86func.js @@ -206,21 +206,22 @@ X86.fnBOUND = function BOUND(dst, src) */ X86.fnBSF = function BSF(dst, src) { + var n = 0; if (!src) { this.setZF(); } else { this.clearZF(); - var i = 0, bit = 0x1; + var bit = 0x1; while (bit & this.dataMask) { if (src & bit) { - dst = i; + dst = n; break; } bit <<= 1; - i++; + n++; // TODO: Determine if n should be incremented before the bailout for an accurate cycle count } } - this.nStepCycles -= this.cycleCounts.nOpCyclesBitScan + i * 3; + this.nStepCycles -= this.cycleCounts.nOpCyclesBitScan + n * 3; return dst; }; @@ -241,21 +242,23 @@ X86.fnBSF = function BSF(dst, src) */ X86.fnBSR = function BSR(dst, src) { + var n = 0; if (!src) { this.setZF(); } else { this.clearZF(); - var i = (this.dataSize == 2? 15 : 31), j = i, bit = 1 << i; + var i = (this.dataSize == 2? 15 : 31), bit = 1 << i; while (bit) { if (src & bit) { dst = i; break; } bit >>>= 1; - i--; + n++; i--; // TODO: Determine if n should be incremented before the bailout for an accurate cycle count } + } - this.nStepCycles -= this.cycleCounts.nOpCyclesBitScan + (j - i) * 3; + this.nStepCycles -= this.cycleCounts.nOpCyclesBitScan + n * 3; return dst; }; diff --git a/modules/pcjs/lib/x86op0f.js b/modules/pcjs/lib/x86op0f.js index 4f6fd392c..d5f5b0d99 100644 --- a/modules/pcjs/lib/x86op0f.js +++ b/modules/pcjs/lib/x86op0f.js @@ -309,8 +309,6 @@ X86.opMOVcr = function MOVcr() this.regCR3 = this.regEBX; this.regEBX = temp; break; - default: - break; // there IS no other case, but JavaScript inspections don't know that } }; diff --git a/modules/pcjs/lib/x86seg.js b/modules/pcjs/lib/x86seg.js index 7af515a63..131edb16d 100644 --- a/modules/pcjs/lib/x86seg.js +++ b/modules/pcjs/lib/x86seg.js @@ -152,6 +152,10 @@ X86Seg.prototype.loadProt = function loadProt(sel, fSuppress) var addrDTLimit; var cpu = this.cpu; + /* + * Some instructions (eg, CALLF) load a 32-bit value for the selector, while others (eg, LDS) do not; + * however, in ALL cases, only the low 16 bits are significant. + */ sel &= 0xffff; if (!(sel & X86.SEL.LDT)) {