Added support for future PDP-10 MACRO-10 assembler
This commit is contained in:
parent
3a9cd5cf04
commit
fcee8a2838
7 changed files with 366 additions and 224 deletions
|
|
@ -6325,7 +6325,7 @@ PDP10.merge72 = function(dst, ext)
|
|||
/*
|
||||
* Let's assert that the sign bits of both halves match.
|
||||
*/
|
||||
Component.assert(sign == (dst - (dst % PDP10.INT_LIMIT)), "sign mismatch");
|
||||
this.assert(sign == (dst - (dst % PDP10.INT_LIMIT)), "sign mismatch");
|
||||
|
||||
/*
|
||||
* Compute value without the sign bit and add the low bit of extended in its place.
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ if (NODE) {
|
|||
var BusPDP10 = require("./bus");
|
||||
var MemoryPDP10 = require("./memory");
|
||||
var MessagesPDP10 = require("./messages");
|
||||
var Macro10 = require("./macro10");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -77,6 +78,7 @@ class DebuggerPDP10 extends Debugger {
|
|||
* The DebuggerPDP10 component is an optional component that implements a variety of user
|
||||
* commands for controlling the CPU, dumping and editing memory, etc.
|
||||
*
|
||||
* @this {DebuggerPDP10}
|
||||
* @param {Object} parmsDbg
|
||||
*/
|
||||
constructor(parmsDbg)
|
||||
|
|
@ -174,6 +176,13 @@ class DebuggerPDP10 extends Debugger {
|
|||
this.controlDebug = null;
|
||||
this.panel = null;
|
||||
|
||||
/**
|
||||
* This records any active Macro10 assembler object.
|
||||
*
|
||||
* @type {Macro10|null}
|
||||
*/
|
||||
this.macro10 = null;
|
||||
|
||||
/*
|
||||
* Make it easier to access DebuggerPDP10 commands from an external REPL (eg, the WebStorm
|
||||
* "live" console window); eg:
|
||||
|
|
@ -2430,11 +2439,23 @@ class DebuggerPDP10 extends Debugger {
|
|||
return dbgAddr;
|
||||
}
|
||||
|
||||
/**
|
||||
* loadAssembly(macro10, addrLoad)
|
||||
*
|
||||
* @this {DebuggerPDP10}
|
||||
* @param {Macro10} macro10
|
||||
* @param {number|null} addrLoad
|
||||
*/
|
||||
loadAssembly(macro10, addrLoad)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* returnSymbol(iTable, iOffset, aSymbol)
|
||||
*
|
||||
* Helper function for findSymbol().
|
||||
*
|
||||
* @this {DebuggerPDP10}
|
||||
* @param {number} iTable
|
||||
* @param {number} iOffset
|
||||
* @param {Array} aSymbol is updated with the specified symbol, if it exists
|
||||
|
|
@ -2517,6 +2538,25 @@ class DebuggerPDP10 extends Debugger {
|
|||
return;
|
||||
}
|
||||
|
||||
if (sOpCode.indexOf(':') >= 0) {
|
||||
var dbg = this;
|
||||
if (this.macro10) {
|
||||
dbg.println("assembly already in progress");
|
||||
}
|
||||
else {
|
||||
var addrLoad = dbgAddr.addr;
|
||||
this.macro10 = new Macro10(sOpCode, addrLoad, dbg, function(macro10, sURL, nErrorCode) {
|
||||
if (!nErrorCode) {
|
||||
dbg.loadAssembly(macro10, addrLoad);
|
||||
} else {
|
||||
dbg.println("error assembling " + sURL + ": (" + nErrorCode + ")");
|
||||
}
|
||||
dbg.macro10 = null;
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
asArgs.shift();
|
||||
asArgs.shift();
|
||||
asArgs.shift();
|
||||
|
|
|
|||
92
modules/pdp10/lib/macro10.js
Normal file
92
modules/pdp10/lib/macro10.js
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
/**
|
||||
* @fileoverview My homage to MACRO-10: a work-alike assembler for the PDP-10
|
||||
* @author <a href="mailto:Jeff@pcjs.org">Jeff Parsons</a>
|
||||
* @copyright © Jeff Parsons 2012-2017
|
||||
*
|
||||
* 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 modified copy of this work
|
||||
* and to display that copyright notice when the software starts running; see COPYRIGHT in
|
||||
* <http://pcjs.org/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";
|
||||
|
||||
if (NODE) {
|
||||
var Str = require("../../shared/lib/strlib");
|
||||
var Web = require("../../shared/lib/weblib");
|
||||
var Debugger = require("../../shared/lib/debugger");
|
||||
var PDP10 = require("./defines");
|
||||
var DebuggerPDP10 = require("./debugger");
|
||||
}
|
||||
|
||||
/**
|
||||
* @class Macro10
|
||||
*/
|
||||
class Macro10 {
|
||||
/**
|
||||
* Macro10(sURL, nAddr, dbg, done)
|
||||
*
|
||||
* The done() callback is called after the resource has been loaded and parsed, with an error code
|
||||
* indicating overall success or failure. The caller must use other methods to obtain further results.
|
||||
*
|
||||
* The callback is passed three parameters:
|
||||
*
|
||||
* done(macro10, sURL, nErrorCode)
|
||||
*
|
||||
* If nErrorCode is zero, the assembly process completed successfully.
|
||||
*
|
||||
* For access to basic services (eg, println()), we rely on the caller. This is NOT an extension of
|
||||
* Component, so those services are NOT part of this class.
|
||||
*
|
||||
* @this {Macro10}
|
||||
* @param {string} sURL (the URL of the resource to be assembled)
|
||||
* @param {number|null} nAddr (the absolute address to assemble the code at, if any)
|
||||
* @param {DebuggerPDP10} dbg (used to provide services like println() to the Macro10 class)
|
||||
* @param {function(Macro10,string,number)} done
|
||||
*/
|
||||
constructor(sURL, nAddr, dbg, done)
|
||||
{
|
||||
this.sURL = sURL;
|
||||
this.nAddr = nAddr;
|
||||
this.dbg = dbg;
|
||||
this.done = done;
|
||||
var macro10 = this;
|
||||
Web.getResource(sURL, null, true, function(sURL, sResource, nErrorCode) {
|
||||
if (!nErrorCode) {
|
||||
nErrorCode = macro10.parse(sResource);
|
||||
}
|
||||
macro10.done(macro10, sURL, nErrorCode);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* parse(sResource)
|
||||
*
|
||||
* Begin the assembly process.
|
||||
*
|
||||
* @this {Macro10}
|
||||
* @param {string} sResource
|
||||
* @return {number}
|
||||
*/
|
||||
parse(sResource) {
|
||||
this.dbg.println("resource length: " + sResource.length);
|
||||
return 999;
|
||||
}
|
||||
}
|
||||
|
|
@ -149,7 +149,14 @@ class Web {
|
|||
*
|
||||
* Request the specified resource (sURL), and once the request is complete, notify done().
|
||||
*
|
||||
* Also, if dataPost is set to a string, that string can be used to control the response format;
|
||||
* If fAsync is true, a done() callback should ALWAYS be supplied; otherwise, you'll have no
|
||||
* idea when the request is complete or what the response was. done() is passed three parameters:
|
||||
*
|
||||
* done(sURL, sResource, nErrorCode)
|
||||
*
|
||||
* If nErrorCode is zero, sResource should contain the requested data; otherwise, an error occurred.
|
||||
*
|
||||
* If dataPost is set to a string, that string can be used to control the response format;
|
||||
* by default, the response format is plain text, but you can specify "bytes" to request arbitrary
|
||||
* binary data, which should come back as a string of bytes.
|
||||
*
|
||||
|
|
@ -157,8 +164,6 @@ class Web {
|
|||
* Instead, we should implement supported response types ("text" and "arraybuffer", at a minimum)
|
||||
* by setting xmlHTTP.responseType to one of those values before calling xmlHTTP.send().
|
||||
*
|
||||
* ES6 ALERT: Default parameters.
|
||||
*
|
||||
* @param {string} sURL
|
||||
* @param {string|Object|null} [dataPost] for a POST request (default is a GET request)
|
||||
* @param {boolean} [fAsync] is true for an asynchronous request
|
||||
|
|
|
|||
Loading…
Reference in a new issue