Show display in hex

This commit is contained in:
n loewen 2023-08-02 15:05:55 +01:00
parent 4c75b36bbb
commit 7b3ec6b025
1 changed files with 3 additions and 8 deletions

View File

@ -1,14 +1,9 @@
const { START_OF_DISPLAY_MEM } = require('./machine.config');
const { num2hex } = require('./logging.js');
exports.printDisplay = (mem) => {
const disp = START_OF_DISPLAY_MEM;
for (let i = disp; i < disp + 16; i += 4) {
console.log(`${pad(mem[i])} ${pad(mem[i+1])} ${pad(mem[i+2])} ${pad(mem[i+3])}`);
console.log(`${num2hex(mem[i])} ${num2hex(mem[i+1])} ${num2hex(mem[i+2])} ${num2hex(mem[i+3])}`);
}
}
const num2hex = (num) => num.toString(16).toUpperCase().padStart(2, "0");
function pad(n) {
return n.toString().padStart(3, "0");
};
}