From 6883adcd71e0e1eceddaf7b6a0e94d965351d897 Mon Sep 17 00:00:00 2001 From: n loewen Date: Wed, 2 Aug 2023 15:28:18 +0100 Subject: [PATCH] Fix/implement relocatable display memory --- assembler.js | 4 ++-- display.js | 5 +++-- machine.config.js | 2 +- test-programs/relocate-display-mem.asm | 8 ++++++++ 4 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 test-programs/relocate-display-mem.asm diff --git a/assembler.js b/assembler.js index a2ebae4..37d31f9 100644 --- a/assembler.js +++ b/assembler.js @@ -1,5 +1,5 @@ const { logMemory, num2hex } = require('./logging.js'); -const { INITIAL_IP_ADDRESS, START_OF_DISPLAY_MEM } = require('./machine.config.js'); +const { INITIAL_IP_ADDRESS, POINTER_TO_START_OF_DISPLAY_MEM } = require('./machine.config.js'); // 1 = verbose // 2 = what i'm currently focusing on @@ -30,7 +30,7 @@ function decodeInstructions(str) { let lines = str.split(/\n/); // returns an array of lines let machineCode = new Array(INITIAL_IP_ADDRESS).fill(0); - machineCode[0] = START_OF_DISPLAY_MEM; + machineCode[0] = POINTER_TO_START_OF_DISPLAY_MEM; let labels = {}; let IP = INITIAL_IP_ADDRESS; diff --git a/display.js b/display.js index 09da52e..c5e5a16 100644 --- a/display.js +++ b/display.js @@ -1,8 +1,9 @@ -const { START_OF_DISPLAY_MEM } = require('./machine.config'); +const { POINTER_TO_START_OF_DISPLAY_MEM } = require('./machine.config'); const { num2hex } = require('./logging.js'); exports.printDisplay = (mem) => { - const disp = START_OF_DISPLAY_MEM; + const disp = mem[POINTER_TO_START_OF_DISPLAY_MEM]; + console.log('disp', disp); for (let i = disp; i < disp + 16; i += 4) { console.log(`${num2hex(mem[i])} ${num2hex(mem[i+1])} ${num2hex(mem[i+2])} ${num2hex(mem[i+3])}`); } diff --git a/machine.config.js b/machine.config.js index c95aba7..d8dac63 100644 --- a/machine.config.js +++ b/machine.config.js @@ -1,6 +1,6 @@ module.exports = { "INITIAL_IP_ADDRESS": 48, - "START_OF_DISPLAY_MEM": 0, + "POINTER_TO_START_OF_DISPLAY_MEM": 0, // max number of times to step the CPU, // to stop endless loops diff --git a/test-programs/relocate-display-mem.asm b/test-programs/relocate-display-mem.asm new file mode 100644 index 0000000..f9e5cc4 --- /dev/null +++ b/test-programs/relocate-display-mem.asm @@ -0,0 +1,8 @@ +;; test re-locating display memory +LDA $10 +STO $00 ; change pointer-to-display-memory to $10 +STO $10 +STO $11 +STO $12 +STO $13 +END \ No newline at end of file