Fix/implement relocatable display memory

This commit is contained in:
n loewen 2023-08-02 15:28:18 +01:00
parent 18ccc4d2df
commit 6883adcd71
4 changed files with 14 additions and 5 deletions

View File

@ -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;

View File

@ -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])}`);
}

View File

@ -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

View File

@ -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