First batch of pdp11.js code adapted but totally untested

This commit is contained in:
Jeff Parsons 2016-09-05 11:05:40 -07:00
commit 100779e30a
22 changed files with 2697 additions and 1273 deletions

View file

@ -1035,6 +1035,17 @@ CPU8080.prototype.updateTimers = function(nCycles)
}
};
/**
* endBurst()
*
* @this {CPU8080}
*/
CPU8080.prototype.endBurst = function()
{
this.nBurstCycles -= this.nStepCycles;
this.nStepCycles = 0;
};
/**
* runCPU(fUpdateFocus)
*
@ -1170,8 +1181,7 @@ CPU8080.prototype.stepCPU = function(nMinCycles)
CPU8080.prototype.stopCPU = function(fComplete)
{
this.isBusy(true);
this.nBurstCycles -= this.nStepCycles;
this.nStepCycles = 0;
this.endBurst();
this.addCycles(this.nRunCycles);
this.nRunCycles = 0;
if (this.flags.fRunning) {
@ -1212,9 +1222,8 @@ CPU8080.prototype.updateCPU = function(fForce)
*/
CPU8080.prototype.yieldCPU = function()
{
this.endBurst(); // this will break us out of stepCPU()
this.nCyclesNextYield = 0; // this will break us out of runCPU(), once we break out of stepCPU()
this.nBurstCycles -= this.nStepCycles;
this.nStepCycles = 0; // this will break us out of stepCPU()
// if (DEBUG) this.nSnapCycles = this.nBurstCycles;
/*
* The Debugger calls yieldCPU() after every message() to ensure browser responsiveness, but it looks

View file

@ -961,8 +961,7 @@ CPUState8080.prototype.checkINTR = function()
* current burst AND that it should not execute any more instructions until checkINTR() indicates
* that a hardware interrupt has been requested.
*/
this.nBurstCycles -= this.nStepCycles;
this.nStepCycles = 0;
this.endBurst();
return false;
}
return true;
@ -994,8 +993,7 @@ CPUState8080.prototype.clearINTR = function(nLevel)
CPUState8080.prototype.requestHALT = function()
{
this.intFlags |= CPUDef8080.INTFLAG.HALT;
this.nBurstCycles -= this.nStepCycles;
this.nStepCycles = 0;
this.endBurst();
};
/**
@ -1015,8 +1013,7 @@ CPUState8080.prototype.requestINTR = function(nLevel)
{
this.intFlags |= (1 << nLevel);
if (this.getIF()) {
this.nBurstCycles -= this.nStepCycles;
this.nStepCycles = 0;
this.endBurst();
}
};
@ -1088,9 +1085,6 @@ CPUState8080.prototype.updateStatus = function(fForce)
* they're all one continuous stream of instructions that can be stepped or run at will. Moreover,
* stepping vs. running should never change the behavior of the simulation.
*
* As a result, the Debugger's complete independence means you can run other 8086/8088 debuggers
* (eg, DEBUG) inside the simulation without interference; you can even "debug" them with the Debugger.
*
* @this {CPUState8080}
* @param {number} nMinCycles (0 implies a single-step, and therefore breakpoints should be ignored)
* @return {number} of cycles executed; 0 indicates a pre-execution condition (ie, an execution breakpoint

View file

@ -939,6 +939,17 @@ CPU.prototype.calcRemainingTime = function()
return msRemainsThisRun;
};
/**
* endBurst()
*
* @this {CPU}
*/
CPU.prototype.endBurst = function()
{
this.nBurstCycles -= this.nStepCycles;
this.nStepCycles = 0;
};
/**
* runCPU(fUpdateFocus)
*
@ -1089,8 +1100,7 @@ CPU.prototype.stepCPU = function(nMinCycles)
CPU.prototype.stopCPU = function(fComplete)
{
this.isBusy(true);
this.nBurstCycles -= this.nStepCycles;
this.nStepCycles = 0;
this.endBurst();
this.addCycles(this.nRunCycles);
this.nRunCycles = 0;
if (this.flags.fRunning) {
@ -1131,9 +1141,8 @@ CPU.prototype.updateCPU = function(fForce)
*/
CPU.prototype.yieldCPU = function()
{
this.endBurst(); // this will break us out of stepCPU()
this.aCounts.nCyclesNextYield = 0; // this will break us out of runCPU(), once we break out of stepCPU()
this.nBurstCycles -= this.nStepCycles;
this.nStepCycles = 0; // this will break us out of stepCPU()
// if (DEBUG) this.nSnapCycles = this.nBurstCycles;
/*
* The Debugger calls yieldCPU() after every message() to ensure browser responsiveness, but it looks

View file

@ -17,7 +17,6 @@ PDP11 is currently comprised of the following non-shared components, as listed i
[package.json](../../package.json) (see the *pdp11Files* property):
* [defines.js](/modules/pdp11/lib/defines.js)
* [cpudef.js](/modules/pdp11/lib/cpudef.js)
* [messages.js](/modules/pdp11/lib/messages.js)
* [panel.js](/modules/pdp11/lib/panel.js)
* [bus.js](/modules/pdp11/lib/bus.js)

View file

@ -0,0 +1,64 @@
/**
* @fileoverview Converts octal constants to hex.
* @author <a href="mailto:Jeff@pcjs.org">Jeff Parsons</a>
* @version 1.0
* Created 2016-Sep-04
*
* Copyright © 2012-2016 Jeff Parsons <Jeff@pcjs.org>
*
* This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
*
* PCjs is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCjs. If not,
* see <http://www.gnu.org/licenses/gpl.html>.
*
* You are required to include the above copyright notice in every source code file of every
* copy or modified version of this work, and to display that copyright notice on every screen
* that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
*
* Some PCjs files also attempt to load external resource files, such as character-image files,
* ROM files, and disk image files. Those external resource files are not considered part of PCjs
* for purposes of the GNU General Public License, and the author does not claim any copyright
* as to their contents.
*/
"use strict";
var fs = require("fs");
try {
var sText = fs.readFileSync(process.argv[2], "utf-8");
var asLines = sText.split('\n');
for (var iLine = 0; iLine < asLines.length; iLine++) {
var sLine = asLines[iLine];
var match, re = /([^0-9a-z_-])(0[0-7]+)([^0-9a-z_])/gi;
var iComment = sLine.indexOf("//");
while (match = re.exec(sLine)) {
if (iComment >= 0 && match.index > iComment) break;
var n = parseInt(match[2], 8);
if (n < 0) {
console.log("found negative octal value (" + match[2] + "), skipping");
continue;
}
var sReplace = match[1] + "0x" + n.toString(16).toUpperCase() + match[3] + " /*" + match[2] + "*/";
sLine = sLine.substr(0, match.index) + sReplace + sLine.substr(match.index + match[0].length);
re.lastIndex = match.index + sReplace.length;
asLines[iLine] = sLine;
}
}
sText = "";
for (var iLine = 0; iLine < asLines.length; iLine++) {
if (sText) sText += '\n';
sText += asLines[iLine];
}
console.log(sText);
} catch (err) {
console.log("error: " + err.message);
}

View file

@ -739,6 +739,40 @@ BusPDP11.prototype.restoreMemory = function(a)
return true;
};
/**
* reset_iopage()
*
* TODO: Implement
*
* @this {BusPDP11}
*/
BusPDP11.prototype.reset_iopage = function()
{
// display.misc = (display.misc & ~0x77) | 0x14; // kernel 16 bit
// tty.rcsr = 0;
// tty.xcsr = 0x80; /*0200*/
// kw11.csr = 0;
// rk11.rkcs = 0x80; /*0200*/
// rl11.csr = 0x80;
// rp11_init();
};
/**
* access_iopage(physicalAddress, data, byteFlag)
*
* TODO: Implement
*
* @this {BusPDP11}
* @param {number} physicalAddress
* @param {number} data
* @param {number} byteFlag
* @return {number}
*/
BusPDP11.prototype.access_iopage = function(physicalAddress, data, byteFlag)
{
return -1;
};
/**
* reportError(op, addr, size, fQuiet)
*

View file

@ -1037,6 +1037,17 @@ CPUPDP11.prototype.updateTimers = function(nCycles)
}
};
/**
* endBurst()
*
* @this {CPUPDP11}
*/
CPUPDP11.prototype.endBurst = function()
{
this.nBurstCycles -= this.nStepCycles;
this.nStepCycles = 0;
};
/**
* runCPU(fUpdateFocus)
*
@ -1172,8 +1183,7 @@ CPUPDP11.prototype.stepCPU = function(nMinCycles)
CPUPDP11.prototype.stopCPU = function(fComplete)
{
this.isBusy(true);
this.nBurstCycles -= this.nStepCycles;
this.nStepCycles = 0;
this.endBurst();
this.addCycles(this.nRunCycles);
this.nRunCycles = 0;
if (this.flags.fRunning) {
@ -1213,9 +1223,8 @@ CPUPDP11.prototype.updateCPU = function(fForce)
*/
CPUPDP11.prototype.yieldCPU = function()
{
this.endBurst(); // this will break us out of stepCPU()
this.nCyclesNextYield = 0; // this will break us out of runCPU(), once we break out of stepCPU()
this.nBurstCycles -= this.nStepCycles;
this.nStepCycles = 0; // this will break us out of stepCPU()
// if (DEBUG) this.nSnapCycles = this.nBurstCycles;
/*
* The Debugger calls yieldCPU() after every message() to ensure browser responsiveness, but it looks

View file

@ -1,115 +0,0 @@
/**
* @fileoverview Defines PDP11 CPU constants.
* @author <a href="mailto:Jeff@pcjs.org">Jeff Parsons</a>
* @version 1.0
* Created 2016-Sep-03
*
* This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
*
* It has been adapted from the JavaScript PDP 11/70 Emulator v1.3 written by Paul Nankervis
* (paulnank@hotmail.com) as of August 2016 from http://skn.noip.me/pdp11/pdp11.html. This code
* may be used freely provided the original author name is acknowledged in any modified source code.
*
* PCjs is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCjs. If not,
* see <http://www.gnu.org/licenses/gpl.html>.
*
* You are required to include the above copyright notice in every source code file of every
* copy or modified version of this work, and to display that copyright notice on every screen
* that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
*
* Some PCjs files also attempt to load external resource files, such as character-image files,
* ROM files, and disk image files. Those external resource files are not considered part of PCjs
* for purposes of the GNU General Public License, and the author does not claim any copyright
* as to their contents.
*/
"use strict";
var CPUDefPDP11 = {
/*
* CPU model numbers (supported)
*/
MODEL_1145: 1145,
MODEL_1170: 1170,
/*
* This constant is used to mark points in the code where the physical address being returned
* is invalid and should not be used.
*
* In a 32-bit CPU, -1 (ie, 0xffffffff) could actually be a valid address, so consider changing
* ADDR_INVALID to NaN or null (which is also why all ADDR_INVALID tests should use strict equality
* operators).
*
* The main reason I'm NOT using NaN or null now is my concern that, by mixing non-numbers
* (specifically, values outside the range of signed 32-bit integers), performance may suffer.
*
* WARNING: Like many of the properties defined here, ADDR_INVALID is a common constant, which the
* Closure Compiler will happily inline (with or without @const annotations; in fact, I've yet to
* see a @const annotation EVER improve automatic inlining). However, if you don't make ABSOLUTELY
* certain that this file is included BEFORE the first reference to any of these properties, that
* automatic inlining will no longer occur.
*/
ADDR_INVALID: -1,
/*
* Processor Status flag definitions (stored in regPS)
*/
PS: {
CF: 0x0001, // bit 0: Carry Flag
BIT1: 0x0002, // bit 1: reserved, always set
PF: 0x0004, // bit 2: Parity Flag
BIT3: 0x0008, // bit 3: reserved, always clear
AF: 0x0010, // bit 4: Auxiliary Carry Flag
BIT5: 0x0020, // bit 5: reserved, always clear
ZF: 0x0040, // bit 6: Zero Flag
SF: 0x0080, // bit 7: Sign Flag
ALL: 0x00D5, // all "arithmetic" flags (CF, PF, AF, ZF, SF)
MASK: 0x00FF, //
IF: 0x0200 // bit 9: Interrupt Flag (set if interrupts enabled; Intel calls this the INTE bit)
},
/*
* Interrupt-related flags (stored in intFlags)
*/
INTFLAG: {
NONE: 0x0000,
INTR: 0x00ff, // mask for 8 bits, representing interrupt levels 0-7
HALT: 0x0100 // halt requested; see opHLT()
},
/*
* Opcode definitions
*/
OPCODE: {
HLT: 0x76, // Halt
ACI: 0xCE, // Add with Carry Immediate (affects PS.ALL)
CALL: 0xCD, // Call
RST0: 0xC7
// to be continued....
}
};
/*
* These are the internal PS bits (outside of PS.MASK) that getPS() and setPS() can get and set,
* but which cannot be seen with any of the documented instructions.
*/
CPUDefPDP11.PS.INTERNAL = (CPUDefPDP11.PS.IF);
/*
* PS "arithmetic" flags are NOT stored in regPS; they are maintained across separate result registers,
* hence the RESULT designation.
*/
CPUDefPDP11.PS.RESULT = (CPUDefPDP11.PS.CF | CPUDefPDP11.PS.PF | CPUDefPDP11.PS.AF | CPUDefPDP11.PS.ZF | CPUDefPDP11.PS.SF);
/*
* These are the "always set" PS bits for the PDP11.
*/
CPUDefPDP11.PS.SET = (CPUDefPDP11.PS.BIT1);
if (NODE) module.exports = CPUDefPDP11;

View file

@ -35,7 +35,7 @@
if (NODE) {
var str = require("../../shared/lib/strlib");
var CPUDefPDP11 = require("./CPUDef");
var PDP11 = require("./defines");
var MessagesPDP11 = require("./messages");
}
@ -44,7 +44,7 @@ if (NODE) {
*
* @this {CPUStatePDP11}
*/
CPUDefPDP11.opNOP = function()
PDP11.opNOP = function()
{
this.nStepCycles -= 4;
};
@ -56,69 +56,69 @@ CPUDefPDP11.opNOP = function()
* but I suspect that would vary quite a bit across JavaScript engines; for now, I'm putting my
* money on array lookup.
*/
CPUDefPDP11.aOpsPDP1170 = [
/* 0x00-0x03 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x04-0x07 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x08-0x0B */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x0C-0x0F */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x10-0x13 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x14-0x17 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x18-0x1B */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x1C-0x1F */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x20-0x23 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x24-0x27 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x28-0x2B */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x2C-0x2F */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x30-0x33 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x34-0x37 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x38-0x3B */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x3C-0x3F */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x40-0x43 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x44-0x47 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x48-0x4B */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x4C-0x4F */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x50-0x53 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x54-0x57 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x58-0x5B */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x5C-0x5F */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x60-0x63 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x64-0x67 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x68-0x6B */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x6C-0x6F */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x70-0x73 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x74-0x77 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x78-0x7B */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x7C-0x7F */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x80-0x83 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x84-0x87 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x88-0x8B */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x8C-0x8F */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x90-0x93 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x94-0x97 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x98-0x9B */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0x9C-0x9F */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xA0-0xA3 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xA4-0xA7 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xA8-0xAB */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xAC-0xAF */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xB0-0xB3 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xB4-0xB7 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xB8-0xBB */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xBC-0xBF */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xC0-0xC3 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xC4-0xC7 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xC8-0xCB */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xCC-0xCF */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xD0-0xD3 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xD4-0xD7 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xD8-0xDB */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xDC-0xDF */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xE0-0xE3 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xE4-0xE7 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xE8-0xEB */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xEC-0xEF */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xF0-0xF3 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xF4-0xF7 */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xF8-0xFB */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP,
/* 0xFC-0xFF */ CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP, CPUDefPDP11.opNOP
PDP11.aOpsPDP1170 = [
/* 0x00-0x03 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x04-0x07 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x08-0x0B */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x0C-0x0F */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x10-0x13 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x14-0x17 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x18-0x1B */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x1C-0x1F */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x20-0x23 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x24-0x27 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x28-0x2B */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x2C-0x2F */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x30-0x33 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x34-0x37 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x38-0x3B */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x3C-0x3F */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x40-0x43 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x44-0x47 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x48-0x4B */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x4C-0x4F */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x50-0x53 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x54-0x57 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x58-0x5B */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x5C-0x5F */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x60-0x63 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x64-0x67 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x68-0x6B */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x6C-0x6F */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x70-0x73 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x74-0x77 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x78-0x7B */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x7C-0x7F */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x80-0x83 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x84-0x87 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x88-0x8B */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x8C-0x8F */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x90-0x93 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x94-0x97 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x98-0x9B */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0x9C-0x9F */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xA0-0xA3 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xA4-0xA7 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xA8-0xAB */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xAC-0xAF */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xB0-0xB3 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xB4-0xB7 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xB8-0xBB */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xBC-0xBF */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xC0-0xC3 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xC4-0xC7 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xC8-0xCB */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xCC-0xCF */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xD0-0xD3 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xD4-0xD7 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xD8-0xDB */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xDC-0xDF */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xE0-0xE3 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xE4-0xE7 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xE8-0xEB */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xEC-0xEF */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xF0-0xF3 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xF4-0xF7 */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xF8-0xFB */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP,
/* 0xFC-0xFF */ PDP11.opNOP, PDP11.opNOP, PDP11.opNOP, PDP11.opNOP
];

File diff suppressed because it is too large Load diff

View file

@ -41,7 +41,6 @@ if (DEBUGGER) {
var Component = require("../../shared/lib/component");
var State = require("../../shared/lib/state");
var PDP11 = require("./defines");
var CPUDefPDP11 = require("./cpudef");
var CPUPDP11 = require("./cpu");
var KeyboardPDP11 = require("./keyboard");
var MessagesPDP11 = require("./messages");
@ -485,13 +484,13 @@ if (DEBUGGER) {
* @param {DbgAddrPDP11|null|undefined} dbgAddr
* @param {boolean} [fWrite]
* @param {number} [nb] number of bytes to check (1 or 2); default is 1
* @return {number} is the corresponding linear address, or CPUDefPDP11.ADDR_INVALID
* @return {number} is the corresponding linear address, or PDP11.ADDR_INVALID
*/
DebuggerPDP11.prototype.getAddr = function(dbgAddr, fWrite, nb)
{
var addr = dbgAddr && dbgAddr.addr;
if (addr == null) {
addr = CPUDefPDP11.ADDR_INVALID;
addr = PDP11.ADDR_INVALID;
}
return addr;
};
@ -510,7 +509,7 @@ if (DEBUGGER) {
{
var b = 0xff;
var addr = this.getAddr(dbgAddr, false, 1);
if (addr !== CPUDefPDP11.ADDR_INVALID) {
if (addr !== PDP11.ADDR_INVALID) {
b = this.bus.getByteDirect(addr);
if (inc) this.incAddr(dbgAddr, inc);
}
@ -542,7 +541,7 @@ if (DEBUGGER) {
{
var w = 0xffff;
var addr = this.getAddr(dbgAddr, false, 2);
if (addr !== CPUDefPDP11.ADDR_INVALID) {
if (addr !== PDP11.ADDR_INVALID) {
w = this.bus.getShortDirect(addr);
if (inc) this.incAddr(dbgAddr, inc);
}
@ -560,7 +559,7 @@ if (DEBUGGER) {
DebuggerPDP11.prototype.setByte = function(dbgAddr, b, inc)
{
var addr = this.getAddr(dbgAddr, true, 1);
if (addr !== CPUDefPDP11.ADDR_INVALID) {
if (addr !== PDP11.ADDR_INVALID) {
this.bus.setByteDirect(addr, b);
if (inc) this.incAddr(dbgAddr, inc);
this.cpu.updateCPU(true); // we set fForce to true in case video memory was the target
@ -578,7 +577,7 @@ if (DEBUGGER) {
DebuggerPDP11.prototype.setShort = function(dbgAddr, w, inc)
{
var addr = this.getAddr(dbgAddr, true, 2);
if (addr !== CPUDefPDP11.ADDR_INVALID) {
if (addr !== PDP11.ADDR_INVALID) {
this.bus.setShortDirect(addr, w);
if (inc) this.incAddr(dbgAddr, inc);
this.cpu.updateCPU(true); // we set fForce to true in case video memory was the target
@ -648,10 +647,10 @@ if (DEBUGGER) {
* parseAddr(sAddr, fCode, fNoChecks, fPrint)
*
* Address evaluation and validation (eg, range checks) are no longer performed at this stage. That's
* done later, by getAddr(), which returns CPUDefPDP11.ADDR_INVALID for invalid segments, out-of-range offsets,
* done later, by getAddr(), which returns PDP11.ADDR_INVALID for invalid segments, out-of-range offsets,
* etc. The Debugger's low-level get/set memory functions verify all getAddr() results, but even if an
* invalid address is passed through to the Bus memory interfaces, the address will simply be masked with
* BusPDP11.nBusLimit; in the case of CPUDefPDP11.ADDR_INVALID, that will generally refer to the top of the physical
* BusPDP11.nBusLimit; in the case of PDP11.ADDR_INVALID, that will generally refer to the top of the physical
* address space.
*
* @this {DebuggerPDP11}
@ -770,7 +769,7 @@ if (DEBUGGER) {
if (sAddr) {
addr = this.getAddr(this.parseAddr(sAddr));
if (addr === CPUDefPDP11.ADDR_INVALID) {
if (addr === PDP11.ADDR_INVALID) {
this.println("invalid address: " + sAddr);
return;
}
@ -1709,7 +1708,7 @@ if (DEBUGGER) {
if (aBreak != this.aBreakExec) {
var addr = this.getAddr(dbgAddr);
if (addr === CPUDefPDP11.ADDR_INVALID) {
if (addr === PDP11.ADDR_INVALID) {
this.println("invalid address: " + this.toHexAddr(dbgAddr));
fSuccess = false;
} else {
@ -2002,7 +2001,7 @@ if (DEBUGGER) {
var sBytes = "";
var sLine = this.toHexAddr(dbgAddrIns) + ' ';
if (dbgAddrIns.addr !== CPUDefPDP11.ADDR_INVALID && dbgAddr.addr !== CPUDefPDP11.ADDR_INVALID) {
if (dbgAddrIns.addr !== PDP11.ADDR_INVALID && dbgAddr.addr !== PDP11.ADDR_INVALID) {
do {
sBytes += str.toHex(this.getByte(dbgAddrIns, 1), 2);
if (dbgAddrIns.addr == null) break;
@ -2103,9 +2102,6 @@ if (DEBUGGER) {
{
var b;
switch (sFlag) {
case "IF":
b = this.cpu.getIF();
break;
case "SF":
b = this.cpu.getSF();
break;
@ -3236,26 +3232,6 @@ if (DEBUGGER) {
return false;
};
/**
* doInt(sLevel)
*
* @this {DebuggerPDP11}
* @param {string} sLevel
* @return {boolean} true if success, false if error
*/
DebuggerPDP11.prototype.doInt = function(sLevel)
{
if (!this.cpu.getIF()) {
this.println("interrupts disabled (use rif=1 to enable)");
return false;
}
var nLevel = this.parseExpression(sLevel);
if (nLevel == null) return false;
this.println("requesting interrupt level " + nLevel);
this.cpu.requestINTR(nLevel);
return true;
};
/**
* doVar(sCmd)
*
@ -3528,49 +3504,10 @@ if (DEBUGGER) {
fValid = true;
var sRegMatch = sReg.toUpperCase();
switch (sRegMatch) {
case "A":
cpu.regA = w & 0xff;
break;
case "B":
cpu.regB = w & 0xff;
break;
case "BC":
cpu.regB = ((w >> 8) & 0xff);
/* falls through */
case "C":
cpu.regC = w & 0xff;
break;
case "D":
cpu.regD = w & 0xff;
break;
case "DE":
cpu.regD = ((w >> 8) & 0xff);
/* falls through */
case "E":
cpu.regE = w & 0xff;
break;
case "H":
cpu.regH = w & 0xff;
break;
case "HL":
cpu.regH = ((w >> 8) & 0xff);
/* falls through */
case "L":
cpu.regL = w & 0xff;
break;
case "SP":
cpu.setSP(w);
break;
case "PC":
cpu.setPC(w);
this.dbgAddrNextCode = this.newAddr(cpu.getPC());
break;
case "PS":
cpu.setPS(w);
break;
case "PSW":
cpu.setPSW(w);
break;
case "CF":
if (w) cpu.setCF(); else cpu.clearCF();
break;
@ -3580,9 +3517,6 @@ if (DEBUGGER) {
case "SF":
if (w) cpu.setSF(); else cpu.clearSF();
break;
case "IF":
if (w) cpu.setIF(); else cpu.clearIF();
break;
default:
this.println("unknown register: " + sReg);
return;
@ -3668,8 +3602,9 @@ if (DEBUGGER) {
var dbgAddr = this.newAddr(this.cpu.getPC());
var bOpcode = this.getByte(dbgAddr);
/*
switch (bOpcode) {
case CPUDefPDP11.OPCODE.CALL:
case PDP11.OPCODE.CALL:
if (fCallStep) {
this.nStep = nStep;
this.incAddr(dbgAddr, 3);
@ -3678,6 +3613,7 @@ if (DEBUGGER) {
default:
break;
}
*/
if (this.nStep) {
this.setTempBreakpoint(dbgAddr);
@ -4091,13 +4027,6 @@ if (DEBUGGER) {
if (!this.doIf(sCmd.substr(2), fQuiet)) {
result = false;
}
break;
}
if (asArgs[0] == "int") {
if (!this.doInt(asArgs[1])) {
result = false;
}
break;
}
break;
case 'k':

View file

@ -93,9 +93,83 @@ var PDP11 = {
PRIVATE: PRIVATE, // shared
TYPEDARRAYS: TYPEDARRAYS,
SITEHOST: SITEHOST, // shared
XMLVERSION: XMLVERSION // shared
XMLVERSION: XMLVERSION, // shared
/*
* CPU model numbers (supported)
*/
MODEL_1145: 1145,
MODEL_1170: 1170,
/*
* This constant is used to mark points in the code where the physical address being returned
* is invalid and should not be used.
*
* In a 32-bit CPU, -1 (ie, 0xffffffff) could actually be a valid address, so consider changing
* ADDR_INVALID to NaN or null (which is also why all ADDR_INVALID tests should use strict equality
* operators).
*
* The main reason I'm NOT using NaN or null now is my concern that, by mixing non-numbers
* (specifically, values outside the range of signed 32-bit integers), performance may suffer.
*
* WARNING: Like many of the properties defined here, ADDR_INVALID is a common constant, which the
* Closure Compiler will happily inline (with or without @const annotations; in fact, I've yet to
* see a @const annotation EVER improve automatic inlining). However, if you don't make ABSOLUTELY
* certain that this file is included BEFORE the first reference to any of these properties, that
* automatic inlining will no longer occur.
*/
ADDR_INVALID: -1,
/*
* Processor Status flag definitions (stored in regPS)
*/
PS: {
CF: 0x0001, // bit 0: Carry Flag
OF: 0x0002, // bit 1: Overflow Flag
ZF: 0x0004, // bit 2: Zero Flag
SF: 0x0008, // bit 3: Sign Flag
TF: 0x0010, // bit 4: Trap Flag
PRI: 0x00E0, // bits 5-7: Priority
UNUSED: 0x0700, // bits 8-10: unused
REGSET: 0x0800, // bit 11: Register Set
PMODE: 0x3000, // bits 12-13: Previous Mode
CMODE: 0xC000 // bits 14-15: Current Mode
},
/*
* Interrupt-related flags (stored in intFlags)
*/
INTFLAG: {
NONE: 0x0000,
INTR: 0x00ff, // mask for 8 bits, representing interrupt levels 0-7
HALT: 0x0100 // halt requested; see opHLT()
},
/*
* Opcode definitions
*/
OPCODE: {
// to be continued....
},
IOBASE_VIRT: 0x00E000, /*000160000*/
IOBASE_18BIT: 0x03E000, /*000760000*/
IOBASE_UNIBUS: 0x3C0000, /*017000000*/
IOBASE_22BIT: 0x3FE000, /*017760000*/
MAX_MEMORY: 0x3C0000 - 16384, // Maximum memory address (need less memory for BSD 2.9 boot)
MAX_ADDRESS: 0x400000, /*020000000*/ // Register addresses are above 22 bit addressing
BYTE_MODE: 1,
READ_MODE: 2,
WRITE_MODE: 4,
MODIFY_WORD: 2 | 4, // READ_MODE | WRITE_MODE
MODIFY_BYTE: 1 | 2 | 4 // READ_MODE | WRITE_MODE | BYTE_MODE
};
/*
* PS "arithmetic" flags are NOT stored in the PS register; they are maintained across separate result registers,
* hence the RESULT designation.
*/
PDP11.PS.RESULT = (PDP11.PS.CF | PDP11.PS.ZF | PDP11.PS.SF);
if (NODE) {
global.APPCLASS = APPCLASS;
global.APPNAME = APPNAME;

View file

@ -36,7 +36,7 @@
if (NODE) {
var str = require("../../shared/lib/strlib");
var Component = require("../../shared/lib/component");
var CPUDefPDP11 = require("./cpudef");
var PDP11 = require("./defines");
var MessagesPDP11 = require("./messages");
}

View file

@ -40,7 +40,6 @@ if (NODE) {
var Component = require("../../shared/lib/component");
var PDP11 = require("./defines");
var BusPDP11 = require("./bus");
var CPUDefPDP11 = require("./cpudef");
var MemoryPDP11 = require("./memory");
}

View file

@ -39,7 +39,6 @@ if (NODE) {
var DumpAPI = require("../../shared/lib/dumpapi");
var Component = require("../../shared/lib/component");
var PDP11 = require("./defines");
var CPUDefPDP11 = require("./cpudef");
var MemoryPDP11 = require("./memory");
}