diff --git a/sketches/print-memory.js b/sketches/print-memory.js new file mode 100644 index 0000000..1e370cc --- /dev/null +++ b/sketches/print-memory.js @@ -0,0 +1,15 @@ +exports.printTable = (x) => { + console.log(`┌────────┬────────┬────────┐`); + console.log(`│ addr │ op │ arg │`); + console.log(`├────────┼────────┼────────┤`); + for (let i = 0; i < x.length; i += 2) { + console.log(`│ ${leftPadNum(i)} │ ${leftPadNum(x[i])} │ ${leftPadNum(x[i+1])} │`); + if (((i + 2) % 8) === 0) { + console.log(`│ │ │ │`); + } + } + console.log(`└────────┴────────┴────────┘`); + function leftPadNum(n) { + return n.toString().padStart(2, "0") + } +} \ No newline at end of file