1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-29 14:51:17 +00:00

nicer disassembly window

This commit is contained in:
Steven Hugg 2017-01-08 10:51:19 -05:00
parent 6c8d52e64a
commit 65e59d350d
4 changed files with 53 additions and 10 deletions

View File

@ -252,10 +252,12 @@ a.dropdown-toggle {
<script src="codemirror/mode/6502/6502.js"></script> <script src="codemirror/mode/6502/6502.js"></script>
<link rel="stylesheet" href="css/codemirror.css"> <link rel="stylesheet" href="css/codemirror.css">
<link rel="stylesheet" href="codemirror/theme/mbo.css"> <link rel="stylesheet" href="codemirror/theme/mbo.css">
<link rel="stylesheet" href="codemirror/theme/cobalt.css">
<script src="codemirror/addon/search/search.js"></script> <script src="codemirror/addon/search/search.js"></script>
<script src="codemirror/addon/search/searchcursor.js"></script> <script src="codemirror/addon/search/searchcursor.js"></script>
<script src="codemirror/addon/search/jumpToLine.js"></script> <script src="codemirror/addon/search/jumpToLine.js"></script>
<script src="codemirror/addon/dialog/dialog.js"></script> <script src="codemirror/addon/dialog/dialog.js"></script>
<script src="codemirror/addon/selection/active-line.js"></script>
<link rel="stylesheet" href="codemirror/addon/dialog/dialog.css"> <link rel="stylesheet" href="codemirror/addon/dialog/dialog.css">
<script src="javatari.js/release/javatari/javatari.js"></script> <script src="javatari.js/release/javatari/javatari.js"></script>

View File

@ -68,7 +68,7 @@ function formatAbsoluteIndexedY (args) {
} }
function formatIndirect (args) { function formatIndirect (args) {
return this.name + " ($" + formatHex(args[0], 2) + ")"; return this.name + " ($" + formatHex(args[1], 2) + formatHex(args[0], 2) + ")";
} }
function formatIndirectIndexedX (args) { function formatIndirectIndexedX (args) {

View File

@ -51,7 +51,15 @@ var editor = CodeMirror(document.getElementById('editor'), {
tabSize: 8, tabSize: 8,
gutters: ["CodeMirror-linenumbers", "gutter-offset", "gutter-bytes", "gutter-clock", "gutter-info"], gutters: ["CodeMirror-linenumbers", "gutter-offset", "gutter-bytes", "gutter-clock", "gutter-info"],
}); });
//editor.setSize("100%", "95%"); // TODO var disasmview = CodeMirror(document.getElementById('disassembly'), {
mode: '6502',
theme: 'cobalt',
tabSize: 8,
readOnly: true,
styleActiveLine: true,
gutters: ["gutter-offset", "gutter-bytes", "gutter-clock", "gutter-info"],
});
editor.on('changes', function(ed, changeobj) { editor.on('changes', function(ed, changeobj) {
var text = editor.getValue() || ""; var text = editor.getValue() || "";
setCode(text); setCode(text);
@ -705,17 +713,49 @@ function showLoopTimingForCurrentLine() {
function updateDisassembly() { function updateDisassembly() {
var div = $("#disassembly"); var div = $("#disassembly");
if (div.is(':visible')) { if (div.is(':visible')) {
div.empty(); disasmview.clearGutter("gutter-info");
disasmview.clearGutter("gutter-bytes");
disasmview.clearGutter("gutter-offset");
disasmview.clearGutter("gutter-clock");
var state = lastDebugState || platform.saveState(); var state = lastDebugState || platform.saveState();
var mem = state.b; var mem = state.b;
var pc = state.c.PC; var pc = state.c.PC;
var disasm = new Disassembler6502().disassemble(mem, pc, pc+128, pcvisits); var gutters = [];
var selline = 0;
// TODO: not perfect disassembler
function disassemble(start, end) {
if (start < 0) start = 0;
if (end > mem.length) end = mem.length;
var disasm = new Disassembler6502().disassemble(mem, start, end, pcvisits);
var s = ""; var s = "";
for (a in disasm) { for (a in disasm) {
var line = hex(parseInt(a)) + " " + disasm[a] + "\n"; var srclinenum = offset2line[a];
s += line; if (srclinenum) {
var srcline = editor.getLine(srclinenum-1);
if (srcline && srcline.trim().length) {
s += "; " + srclinenum + ":\t" + srcline + "\n";
gutters.push([a]);
} }
$("<pre></pre>").appendTo(div).text(s); }
var dline = hex(parseInt(a)) + "\t" + disasm[a] + "\n";
s += dline;
if (a == pc) selline = gutters.length;
gutters.push([]);
}
return s;
}
var text = disassemble(pc-96, pc) + disassemble(pc, pc+96);
disasmview.setValue(text);
/*
for (var i=0; i<gutters.length; i++) {
var g = gutters[i];
if (g[0]) disasmview.setGutterMarker(i, "gutter-offset", hex(g[0]));
}
*/
disasmview.setCursor(selline, 0);
// TODO: need to refresh when viewport changes
var scrinfo = disasmview.getScrollInfo();
disasmview.scrollTo(0, (scrinfo.height-scrinfo.clientHeight)/2);
} }
} }

View File

@ -181,6 +181,7 @@ function compilePLASMA(code) {
FS.writeFile("main.pla", code); FS.writeFile("main.pla", code);
Module.callMain(["-A"]); Module.callMain(["-A"]);
//console.log("plasm", code.length, "->", outstr.length); //console.log("plasm", code.length, "->", outstr.length);
console.log(outstr);
return assembleACME(outstr); return assembleACME(outstr);
} }
@ -260,7 +261,7 @@ function compileCC65(code, platform) {
var FS = CC65['FS']; var FS = CC65['FS'];
setupFS(FS); setupFS(FS);
FS.writeFile("main.c", code, {encoding:'utf8'}); FS.writeFile("main.c", code, {encoding:'utf8'});
CC65.callMain(['-v', '-T', '-g', '-Oirs', '-I', '/share/include', '-t', platform, "main.c"]); CC65.callMain(['-v', '-T', '-g', '-Cl', '-Oirs', '-I', '/share/include', '-t', platform, "main.c"]);
var asmout = FS.readFile("main.s", {encoding:'utf8'}); var asmout = FS.readFile("main.s", {encoding:'utf8'});
return assemblelinkCA65(asmout, platform); return assemblelinkCA65(asmout, platform);
} }