From 7b3ec6b025c883c9c895feec09c31428c93b689b Mon Sep 17 00:00:00 2001 From: n loewen Date: Wed, 2 Aug 2023 15:05:55 +0100 Subject: [PATCH] Show display in hex --- display.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/display.js b/display.js index b01d63c..09da52e 100644 --- a/display.js +++ b/display.js @@ -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"); -}; \ No newline at end of file +} \ No newline at end of file