From b81b6c8f5accac3ca03f928d845910575b74e29d Mon Sep 17 00:00:00 2001 From: n loewen Date: Wed, 2 Aug 2023 10:52:47 +0100 Subject: [PATCH] Move config constants to a config file --- assembler.js | 3 +-- display.js | 2 +- simulator.js | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/assembler.js b/assembler.js index 7f6f86e..b7dd9c7 100644 --- a/assembler.js +++ b/assembler.js @@ -1,12 +1,11 @@ const printMemory = require('./print-memory.js'); +const { INITIAL_IP_ADDRESS, START_OF_DISPLAY_MEM } = require('./machine.config.js'); // 1 = verbose // 2 = what i'm currently focusing on // 3 = always print // 4 = silent const DEBUG = 4; -const INITIAL_IP_ADDRESS = 48; -const START_OF_DISPLAY_MEM = 0; const mnemonicsWithOptionalArgs = ['end', 'cfc', 'chp']; const mnemonics2opcodes = { diff --git a/display.js b/display.js index 0373ac3..b01d63c 100644 --- a/display.js +++ b/display.js @@ -1,4 +1,4 @@ -const START_OF_DISPLAY_MEM = 0; +const { START_OF_DISPLAY_MEM } = require('./machine.config'); exports.printDisplay = (mem) => { const disp = START_OF_DISPLAY_MEM; diff --git a/simulator.js b/simulator.js index 868a12c..abc3b1e 100644 --- a/simulator.js +++ b/simulator.js @@ -3,8 +3,7 @@ // - instructions are two bytes long: // one byte for the opcode, one for the argument -const INITIAL_IP_ADDRESS = 48; -const CYCLE_LIMIT = 128; // max number of times to step the CPU, to stop endless loops +const { INITIAL_IP_ADDRESS, CYCLE_LIMIT } = require('./machine.config'); const display = require('./display.js');