Remove unused comments, table-printing function
This commit is contained in:
parent
91c4a068e9
commit
aa08e50eda
13
simulator.js
13
simulator.js
|
|
@ -1,5 +1,4 @@
|
||||||
const { INITIAL_IP_ADDRESS, CYCLE_LIMIT } = require('./machine.config');
|
const { INITIAL_IP_ADDRESS, CYCLE_LIMIT } = require('./machine.config');
|
||||||
|
|
||||||
const display = require('./display.js');
|
const display = require('./display.js');
|
||||||
|
|
||||||
// STATE
|
// STATE
|
||||||
|
|
@ -27,14 +26,12 @@ const Instructions = {
|
||||||
store_lit: (lit) => {
|
store_lit: (lit) => {
|
||||||
console.log('STO lit#');
|
console.log('STO lit#');
|
||||||
CPU.memory[lit] = CPU.Acc;
|
CPU.memory[lit] = CPU.Acc;
|
||||||
// logTableTitled(CPU.memory, 'Current memory');
|
|
||||||
CPU.IP = CPU.IP += 2;
|
CPU.IP = CPU.IP += 2;
|
||||||
},
|
},
|
||||||
|
|
||||||
store_addr: (addr) => {
|
store_addr: (addr) => {
|
||||||
console.log('STO addr');
|
console.log('STO addr');
|
||||||
CPU.memory[CPU.memory[addr]] = CPU.Acc;
|
CPU.memory[CPU.memory[addr]] = CPU.Acc;
|
||||||
//logTableTitled(CPU.memory, 'Memory');
|
|
||||||
CPU.IP = CPU.IP += 2;
|
CPU.IP = CPU.IP += 2;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -127,7 +124,6 @@ const Instructions = {
|
||||||
carry_hop: () => {
|
carry_hop: () => {
|
||||||
console.log("CHP");
|
console.log("CHP");
|
||||||
console.log(` ↳ Memory at IP+2 and +3: ${CPU.memory[CPU.IP+2]}, ${CPU.memory[CPU.IP+3]}`);
|
console.log(` ↳ Memory at IP+2 and +3: ${CPU.memory[CPU.IP+2]}, ${CPU.memory[CPU.IP+3]}`);
|
||||||
// console.table(CPU.memory);
|
|
||||||
if (CPU.CF != 0) {
|
if (CPU.CF != 0) {
|
||||||
CPU.IP += 4;
|
CPU.IP += 4;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -155,7 +151,6 @@ const opcodes2mnemonics = {
|
||||||
};
|
};
|
||||||
|
|
||||||
function stepCPU() {
|
function stepCPU() {
|
||||||
// console.group("Step CPU");
|
|
||||||
console.group(`IP: ${CPU.IP}`);
|
console.group(`IP: ${CPU.IP}`);
|
||||||
let opcode = CPU.memory[CPU.IP];
|
let opcode = CPU.memory[CPU.IP];
|
||||||
let argument = CPU.memory[CPU.IP+1];
|
let argument = CPU.memory[CPU.IP+1];
|
||||||
|
|
@ -166,7 +161,6 @@ function stepCPU() {
|
||||||
|
|
||||||
logCPUState();
|
logCPUState();
|
||||||
console.groupEnd(`IP:`);
|
console.groupEnd(`IP:`);
|
||||||
// console.groupEnd("Step CPU");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.runProgram = async (code, debug = false) => {
|
exports.runProgram = async (code, debug = false) => {
|
||||||
|
|
@ -206,13 +200,6 @@ function logCPUState() {
|
||||||
function num2hex(num) { return num.toString(16) };
|
function num2hex(num) { return num.toString(16) };
|
||||||
function hex2num(hex) { return parseInt(hex, 16) };
|
function hex2num(hex) { return parseInt(hex, 16) };
|
||||||
|
|
||||||
logTableTitled = (memory, tableTitle) => {
|
|
||||||
console.log();
|
|
||||||
console.group(tableTitle);
|
|
||||||
console.table(memory);
|
|
||||||
console.groupEnd(tableTitle);
|
|
||||||
};
|
|
||||||
|
|
||||||
function logRunningHeader() {
|
function logRunningHeader() {
|
||||||
console.log();
|
console.log();
|
||||||
let time = new Date();
|
let time = new Date();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue