diff --git a/doc/compilers.txt b/doc/compilers.txt index 49df1955..03d1e44d 100644 --- a/doc/compilers.txt +++ b/doc/compilers.txt @@ -77,3 +77,10 @@ SWEET16 - Woz's tiny bytecode interpreter on the Apple ][ integer BASIC ROM. Still emcumbered by Apple's copyright for the foreseeable future. http://6502.org/source/interpreters/sweet16.htm +Quetzalcoatl - http://www.kdef.com/geek/vic/quetz.html + +UC65 - https://code.google.com/archive/p/uc65/ + +Cowgol - https://github.com/davidgiven/cowgol + +AcheronVM - https://github.com/AcheronVM/acheronvm diff --git a/doc/notes.txt b/doc/notes.txt index 19b71230..766294b6 100644 --- a/doc/notes.txt +++ b/doc/notes.txt @@ -30,6 +30,8 @@ TODO: - slowdown beam for all platforms? - kbd shortcuts - PC x86 support +- show errors in list +- can't see 1st line in editor sometimes WEB WORKER FORMAT @@ -51,5 +53,42 @@ only build files that have changed build options -build project files +BUILD PROJECT + +local/foo.project/*.* +build all files in project +send update for dependencies at startup (single file version) +should be able to change file w/o reloading (Not platform tho) + +pulldown selects file in project, or goes back to parent +gotta preserve editor windows for each one - window list +make source/disasm window visible when debugging +gutter info/errors in all files + + + +UI REFACTOR + +editor +debugger +disasm view +memory +profile + +separate into files + +window methods: +- set +- mode +- get +- changes +- cursorActivity (inspect) +- gutters (setCompileOutput) +- current line / gutter marker (setCurrentLine / clearCurrentLine) +- source map +- global symbols +- pixel editor / find comment (openBitmapEditorAtCursor) +- update debug window (200 ms) + +file store mirrors that on worker diff --git a/index.html b/index.html index 9e2de388..d6e30564 100644 --- a/index.html +++ b/index.html @@ -233,7 +233,7 @@ ga('send', 'pageview'); - + diff --git a/src/disasm.js b/src/cpu/disasm6502.js similarity index 100% rename from src/disasm.js rename to src/cpu/disasm6502.js diff --git a/src/platform/vcs.js b/src/platform/vcs.js index c7226c6e..8d425f98 100644 --- a/src/platform/vcs.js +++ b/src/platform/vcs.js @@ -134,6 +134,38 @@ var pc2maxclocks = {}; var jsrresult = {}; var MAX_CLOCKS = 76*2; +// [taken, not taken] +var BRANCH_CONSTRAINTS = [ + [{N:0},{N:1}], + [{N:1},{N:0}], + [{V:0},{V:1}], + [{V:1},{V:0}], + [{C:0},{C:1}], + [{C:1},{C:0}], + [{Z:0},{Z:1}], + [{Z:1},{Z:0}] +]; + +function constraintEquals(a,b) { + if (a == null || b == null) + return null; + for (var n in a) { + if (b[n] !== 'undefined') + return a[n] == b[n]; + } + for (var n in b) { + if (a[n] !== 'undefined') + return a[n] == b[n]; + } + return null; +} + +function getClockCountsAtPC(pc) { + var opcode = platform.readAddress(pc); + var meta = platform.getOpcodeMetadata(opcode, pc); + return meta; // minCycles, maxCycles +} + function _traceInstructions(pc, minclocks, maxclocks, subaddr, constraints) { //console.log("trace", hex(pc), minclocks, maxclocks); if (!minclocks) minclocks = 0; diff --git a/src/profileview.js b/src/profileview.js new file mode 100644 index 00000000..94388f89 --- /dev/null +++ b/src/profileview.js @@ -0,0 +1,113 @@ +/* profiler window: currently unused */ + +var profilelist; + +var pcdata = {}; +var prof_reads, prof_writes; +var dumplines; + +function scrollProfileView(_ed) { + _ed.on('scroll', function(ed, changeobj) { + if (profilelist) { + profilelist.container.scrollTop = ed.getScrollInfo().top; + } + }); +} + +function updateProfileWindow() { + if (profilelist && sourcefile) { + $("#profileview").find('[data-index]').each(function(i,e) { + var div = $(e); + var lineno = div.attr('data-index') | 0; + var newtext = getProfileLine(lineno+1); + if (newtext) { + var oldtext = div.text(); + if (oldtext != newtext) + div.text(newtext); + } + }); + } +} + +function createProfileWindow() { + profilelist = new VirtualList({ + w:$("#emulator").width(), + h:$("#emulator").height(), + itemHeight: getVisibleEditorLineHeight(), + totalRows: getVisibleSourceFile().lineCount(), + generatorFn: function(row) { + var div = document.createElement("div"); + div.appendChild(document.createTextNode(".")); + return div; + } + }); + $("#profileview").empty().append(profilelist.container); + updateProfileWindow(); +} + +function resetProfiler() { + prof_reads = []; + prof_writes = []; + pcdata = []; + dumplines = null; +} + +function profileWindowCallback(a,v) { + if (platform.getPC) { + var pc = platform.getPC(); + var pcd = pcdata[pc]; + if (!pcd) { + pcd = pcdata[pc] = {nv:1}; + } + if (a != pc) { + if (v >= 0) { + pcd.lastwa = a; + pcd.lastwv = v; + } else { + pcd.lastra = a; + pcd.lastrv = platform.readAddress(a); + } + } else { + pcd.nv++; + } + } +} + +function getProfileLine(line) { + var srcfile = getVisibleSourceFile(); + var offset = srcfile.line2offset[line]; + var offset2 = srcfile.line2offset[line+1]; + if (!(offset2 > offset)) offset2 = offset+1; + var s = ''; + var nv = 0; + while (offset < offset2) { + var pcd = pcdata[offset]; + if (pcd) { + nv += pcd.nv; + if (pcd.lastra >= 0) { + s += " rd [" + hex(pcd.lastra,4) + "] == " + hex(pcd.lastrv,2); + } + if (pcd.lastwa >= 0) { + s += " wr " + hex(pcd.lastwv,2) + " -> [" + hex(pcd.lastwa,4) + "]"; + } + } + offset++; + } + return nv ? (lpad(nv+"",8) + s) : '.'; +} + +function toggleProfileWindow() { + if ($("#memoryview").is(':visible')) toggleMemoryWindow(); + if ($("#profileview").is(':visible')) { + profilelist = null; + platform.getProbe().deactivate(); + $("#emulator").show(); + $("#profileview").hide(); + } else { + createProfileWindow(); + platform.getProbe().activate(profileWindowCallback); + $("#emulator").hide(); + $("#profileview").show(); + } +} + diff --git a/src/ui.js b/src/ui.js index 7aa96428..fbf04060 100644 --- a/src/ui.js +++ b/src/ui.js @@ -80,7 +80,7 @@ var TOOL_TO_SOURCE_STYLE = { } var worker = new Worker("./src/worker/workermain.js"); -var main_editor; +var editor; var current_output; var current_preset_index = -1; var current_preset_id; @@ -92,7 +92,6 @@ var compparams; var trace_pending_at_pc; var store; var pendingWorkerMessages = 0; -var editor; var disasmview = CodeMirror(document.getElementById('disassembly'), { mode: 'z80', theme: 'cobalt', @@ -100,18 +99,13 @@ var disasmview = CodeMirror(document.getElementById('disassembly'), { readOnly: true, styleActiveLine: true }); -scrollProfileView(disasmview); +//scrollProfileView(disasmview); + +var currentDebugLine; +var lastDebugInfo; +var lastDebugState; var memorylist; -var profilelist; - -function scrollProfileView(_ed) { - _ed.on('scroll', function(ed, changeobj) { - if (profilelist) { - profilelist.container.scrollTop = ed.getScrollInfo().top; - } - }); -} function newEditor(mode) { var isAsm = mode=='6502' || mode =='z80' || mode=='verilog' || mode=='gas'; // TODO @@ -141,11 +135,11 @@ function newEditor(mode) { inspectVariable(editor); } }); - scrollProfileView(editor); + //scrollProfileView(editor); editor.setOption("mode", mode); } -function inspectVariable(editor, name) { +function inspectVariable(ed, name) { var val; if (platform.inspect) { platform.inspect(name); @@ -176,7 +170,7 @@ function updatePreset(current_preset_id, text) { function loadCode(text, fileid) { var tool = platform.getToolForFilename(fileid); - main_editor = newEditor(tool && TOOL_TO_SOURCE_STYLE[tool]); + newEditor(tool && TOOL_TO_SOURCE_STYLE[tool]); editor.setValue(text); // calls setCode() editor.clearHistory(); current_output = null; @@ -444,25 +438,6 @@ function setCode(text) { }); } -function arrayCompare(a,b) { - if (a == null && b == null) return true; - if (a == null) return false; - if (b == null) return false; - if (a.length != b.length) return false; - for (var i=0; i= 0) { - pcd.lastwa = a; - pcd.lastwv = v; - } else { - pcd.lastra = a; - pcd.lastrv = platform.readAddress(a); - } - } else { - pcd.nv++; - } - } -} - -function getProfileLine(line) { - var srcfile = getVisibleSourceFile(); - var offset = srcfile.line2offset[line]; - var offset2 = srcfile.line2offset[line+1]; - if (!(offset2 > offset)) offset2 = offset+1; - var s = ''; - var nv = 0; - while (offset < offset2) { - var pcd = pcdata[offset]; - if (pcd) { - nv += pcd.nv; - if (pcd.lastra >= 0) { - s += " rd [" + hex(pcd.lastra,4) + "] == " + hex(pcd.lastrv,2); - } - if (pcd.lastwa >= 0) { - s += " wr " + hex(pcd.lastwv,2) + " -> [" + hex(pcd.lastwa,4) + "]"; - } - } - offset++; - } - return nv ? (lpad(nv+"",8) + s) : '.'; -} - -function toggleProfileWindow() { - if ($("#memoryview").is(':visible')) toggleMemoryWindow(); - if ($("#profileview").is(':visible')) { - profilelist = null; - platform.getProbe().deactivate(); - $("#emulator").show(); - $("#profileview").hide(); - } else { - createProfileWindow(); - platform.getProbe().activate(profileWindowCallback); - $("#emulator").hide(); - $("#profileview").show(); - } -} - function handleWindowMessage(e) { //console.log("window message", e.data); if (e.data.bytes) { @@ -1327,9 +1152,9 @@ function setupDebugControls(){ } else if (platform.readAddress) { $("#dbg_memory").click(toggleMemoryWindow).show(); } - if (platform.getProbe) { + /*if (platform.getProbe) { $("#dbg_profile").click(toggleProfileWindow).show(); - } + }*/ if (platform.saveState) { // TODO: only show if listing or disasm available $("#dbg_disasm").click(toggleDisassembly).show(); } diff --git a/src/util.js b/src/util.js index ea3cc6d8..170a2e0e 100644 --- a/src/util.js +++ b/src/util.js @@ -1,6 +1,12 @@ +"use strict"; function lpad(s,n) { while(s.length - + diff --git a/viz.html b/viz.html index 4e85c30e..011dd466 100644 --- a/viz.html +++ b/viz.html @@ -39,7 +39,7 @@ div.CodeMirror {

Edit a C source file, and see the Z80 assembly output update in real-time.

-
Powered by @8bitworkshop and the +
Powered by @8bitworkshop and the Small Device C Compiler.
@@ -62,7 +62,10 @@ Javatari = {}; PLATFORMS = {}; - + + + +