-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisassembly.html
More file actions
64 lines (48 loc) · 2.33 KB
/
disassembly.html
File metadata and controls
64 lines (48 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="UTF-8" />
<title>Color Computer web disassembler</title>
<link rel="stylesheet" type="text/css" href="./lib/bootstrap.min.css" />
</head>
<body>
<div id="navbar"></div>
<code id="disassembly"></code>
<script type="module">
import { setupNavBar } from './src/view/setupNavBar.mjs';
import { Section, loadAllSections, getAllSections } from './src/model/section.mjs';
import { disassemble } from './src/modules/disassembler.mjs';
function onLoad() {
setupNavBar();
loadAllSections();
const sections = getAllSections();
let dis = "";
for (let i = 0; i < sections.length; i++)
{
dis += sections[i].name + ":" + " ORG   $" + sections[i].virtualMemoryAddress.toString(16).padStart(4, '0').toUpperCase() + "</br>";
let instructionList = disassemble(sections[i].buffer, sections[i].virtualMemoryAddress);
for (let j = 0; j < instructionList.length; j++)
{
var instruction = instructionList[j];
dis += sections[i].name + ":" + instruction.virtualMemoryAddress.toString(16).padStart(4, '0').toUpperCase() + " ";
let rawData = Uint8Array.from(instruction.rawData);
for (let h = 0; h < rawData.length; ++h)
{
dis += rawData[h].toString(16).padStart(2, '0').toUpperCase()
}
for (let h = rawData.length; h < 4; ++h)
{
dis += " ";
}
dis += " " + instruction.mnemonic;
if (instruction.operandText)
dis += " " + instruction.operandText;
dis += "</br>";
}
}
document.getElementById('disassembly').innerHTML = dis;
}
window.addEventListener("load", onLoad);
</script>
</body>
</html>