Print memory tables in hex
This commit is contained in:
parent
fa3ade15dd
commit
e75049551f
|
|
@ -3,13 +3,12 @@ exports.printTable = (x) => {
|
||||||
console.log(`│ addr │ op │ arg │`);
|
console.log(`│ addr │ op │ arg │`);
|
||||||
console.log(`├────────┼────────┼────────┤`);
|
console.log(`├────────┼────────┼────────┤`);
|
||||||
for (let i = 0; i < x.length; i += 2) {
|
for (let i = 0; i < x.length; i += 2) {
|
||||||
console.log(`│ ${leftPadNum(i)} │ ${leftPadNum(x[i])} │ ${leftPadNum(x[i+1])} │`);
|
console.log(`│ ${num2hex(i)} │ ${num2hex(x[i])} │ ${num2hex(x[i+1])} │`);
|
||||||
if (((i + 2) % 8) === 0) {
|
if (((i + 2) % 8) === 0) {
|
||||||
console.log(`│ │ │ │`);
|
console.log(`│ │ │ │`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(`└────────┴────────┴────────┘`);
|
console.log(`└────────┴────────┴────────┘`);
|
||||||
function leftPadNum(n) {
|
}
|
||||||
return n.toString().padStart(2, "0")
|
|
||||||
}
|
const num2hex = (num) => num.toString(16).toUpperCase().padStart(2, "0");
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue