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