Some PDP-10 disassembler clean-up

This commit is contained in:
Jeff Parsons 2017-02-25 21:19:41 -08:00 • committed by Jeff Parsons
commit 3e30bde786
3 changed files with 94 additions and 78 deletions

View file

@ -3790,7 +3790,7 @@ PDP10.opUndefined = function(opCode)
*/ */
PDP10.opKA10 = function(opCode) PDP10.opKA10 = function(opCode)
{ {
var op = (opCode / PDP10.OPCODE.SHIFT)|0; var op = (opCode / PDP10.OPCODE.O_SHIFT)|0;
PDP10.aOpXXX_KA10[op].call(this, opCode); PDP10.aOpXXX_KA10[op].call(this, opCode);
}; };

View file

@ -3456,10 +3456,15 @@ class DebuggerPDP10 extends Debugger {
/** /**
* doTest() * doTest()
* *
* This function exercises the disassembler by performing look-ups for all possible operation codes
* and displaying the results. It's not intended to be included in the compiled version of the Debugger
* (DEBUG only).
*
* @this {DebuggerPDP10} * @this {DebuggerPDP10}
*/ */
doTest() doTest()
{ {
if (DEBUG) {
var ops = {}, aOpXXX = []; var ops = {}, aOpXXX = [];
var op, opXXX, opCode, sOperation; var op, opXXX, opCode, sOperation;
for (op = 0o00000; op <= 0o77774; op += 4) { for (op = 0o00000; op <= 0o77774; op += 4) {
@ -3480,7 +3485,10 @@ class DebuggerPDP10 extends Debugger {
} }
for (sOperation in ops) { for (sOperation in ops) {
op = ops[sOperation]; op = ops[sOperation];
this.println(sOperation + ": " + this.toStrWord(op * Math.pow(2, 21))); this.println(Str.pad(sOperation + ":", 8) + this.toStrWord(op * Math.pow(2, 21)));
//
// The following code leveraged the disassembler to generate opcode handlers for all known opcodes.
//
// this.println("/**"); // this.println("/**");
// this.println(" * op" + sOperation + "(" + this.toStrWord(op * Math.pow(2, 21)) + ")"); // this.println(" * op" + sOperation + "(" + this.toStrWord(op * Math.pow(2, 21)) + ")");
// this.println(" *"); // this.println(" *");
@ -3491,6 +3499,9 @@ class DebuggerPDP10 extends Debugger {
// this.println("{"); // this.println("{");
// this.println("};\n"); // this.println("};\n");
} }
//
// The following code leveraged the disassembler to generate an opcode dispatch table for all known opcodes.
//
// this.println("PDP10.aOpXXX = ["); // this.println("PDP10.aOpXXX = [");
// for (opXXX = 0o000; opXXX <= 0o777; opXXX++) { // for (opXXX = 0o000; opXXX <= 0o777; opXXX++) {
// sOperation = aOpXXX[opXXX]; // sOperation = aOpXXX[opXXX];
@ -3501,6 +3512,7 @@ class DebuggerPDP10 extends Debugger {
// } // }
// this.println("];"); // this.println("];");
} }
}
/** /**
* DebuggerPDP10.init() * DebuggerPDP10.init()
@ -3634,37 +3646,10 @@ if (DEBUGGER) {
]; ];
/* /*
* PDP-10 opcodes are 36-bit values, many of which use the following layout: * OPTABLE is a collection of masks, and each mask refers to a collection of opcode
* * patterns associated with that mask; the disassembler applies each mask to the opcode,
* 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 * and when a masked opcode matches one of the associated patterns, the corresponding
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 * instruction is considered a match.
* O O O O O O O M M A A A A I X X X X Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
*
* or using modern bit-numbering:
*
* 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
* 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* O O O O O O O M M A A A A I X X X X Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
*
* where OOOOOOOMM represents the operation, and MM (if used) represents the mode:
*
* Mode Suffix Source Destination
* ---- ------ ----- -----------
* 0: BASIC None E AC
* 1: IMMEDIATE I 0,E AC
* 2: MEMORY M AC E
* 3: SELF S E E (and AC if A is non-zero)
*
* Input-output instructions look like:
*
* 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
* 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* 1 1 1 D D D D D D D O O O I X X X X Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
*
* Bits 0-22 (I,X,Y) contain what we call a "reference address" (R), which is used to
* calculate the "effective address" (E). To determine E from R, we must extract I, X,
* and Y from R, set E to Y, then add [X] to E if X is non-zero. If I is zero, then
* we're done; otherwise, we must set set R to [E] and repeat the process.
*/ */
DebuggerPDP10.OPTABLE = { DebuggerPDP10.OPTABLE = {
[PDP10.OPCODE.OPUUO]: { // 0o70000 [PDP10.OPCODE.OPUUO]: { // 0o70000

View file

@ -101,7 +101,37 @@ var PDP10 = {
DATA_LIMIT: Math.pow(2, 36), DATA_LIMIT: Math.pow(2, 36),
/* /*
* Opcode definitions * PDP-10 opcodes are 36-bit values, most of which use the following layout:
*
* 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
* O O O O O O O M M A A A A I X X X X Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
*
* or using modern bit-numbering:
*
* 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
* 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* O O O O O O O M M A A A A I X X X X Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
*
* where OOOOOOOMM represents the operation, and MM (if used) represents the mode:
*
* Mode Suffix Source Destination
* ---- ------ ----- -----------
* 0: BASIC None E AC
* 1: IMMEDIATE I 0,E AC
* 2: MEMORY M AC E
* 3: SELF S E E (and AC if A is non-zero)
*
* Input-output instructions look like:
*
* 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
* 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* 1 1 1 D D D D D D D O O O I X X X X Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
*
* Bits 0-22 (I,X,Y) contain what we call a "reference address" (R), which is used to
* calculate the "effective address" (E). To determine E from R, we must extract I, X,
* and Y from R, set E to Y, then add [X] to E if X is non-zero. If I is zero, then
* we're done; otherwise, we must set set R to [E] and repeat the process.
*/ */
OPCODE: { OPCODE: {
OPMASK: 0o77700, // operation mask OPMASK: 0o77700, // operation mask
@ -115,11 +145,12 @@ var PDP10 = {
FNMASK: 0o17, // accumulator/function mask (after shift) FNMASK: 0o17, // accumulator/function mask (after shift)
IOSHIFT: Math.pow(2, 26), // input-output device code shift IOSHIFT: Math.pow(2, 26), // input-output device code shift
IOMASK: 0o177, // input-output device code mask (after shift) IOMASK: 0o177, // input-output device code mask (after shift)
SHIFT: Math.pow(2, 27), // operation code shift O_SHIFT: Math.pow(2, 27), // operation shift
Y_MASK: 0o777777, O_MASK: 0o777, // operation mask (after shift)
X_SHIFT: 18, I_BIT: 0o20000000, // indirect bit
X_MASK: 0o17, X_SHIFT: 18, // X shift
I_BIT: 0o20000000, X_MASK: 0o17, // X mask (after shift)
Y_MASK: 0o777777, // Y mask
HALT: 0o5304 // operation code for HALT HALT: 0o5304 // operation code for HALT
}, },