Create utility script for pretty-printing memory
This commit is contained in:
parent
36df142538
commit
321d8d1264
|
|
@ -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")
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue