From 436a476affba9be0331071108c43344ab43b5f11 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Mon, 25 Jun 2018 17:47:40 -0600 Subject: [PATCH] working on cc65 listing parse --- doc/notes.txt | 4 ++ src/ui.js | 2 +- src/worker/nodemain.js | 14 +++++- src/worker/workermain.js | 98 +++++++++++++++++++++++++--------------- test/cli/testworker.js | 4 ++ 5 files changed, 84 insertions(+), 38 deletions(-) diff --git a/doc/notes.txt b/doc/notes.txt index 8359f5c5..e33a060c 100644 --- a/doc/notes.txt +++ b/doc/notes.txt @@ -20,6 +20,7 @@ TODO: - multiple breakpoints, expression breakpoints - use localForage (https://github.com/localForage/localForage) +- run apple CPU until boot - cc65 listing file parsing - better disasm/listing selection - disasm for z80 @@ -51,3 +52,6 @@ implicit rules only build files that have changed build options + +build project files + diff --git a/src/ui.js b/src/ui.js index 06decdf3..86d58560 100644 --- a/src/ui.js +++ b/src/ui.js @@ -498,7 +498,7 @@ function setCompileOutput(data) { div.appendChild(tooltip); editor.setGutterMarker(line, "gutter-info", div); } - if (data.errors.length > 0) { + if (data.errors && data.errors.length > 0) { // TODO: move cursor to error line if offscreen? toolbar.addClass("has-errors"); editor.clearGutter("gutter-info"); diff --git a/src/worker/nodemain.js b/src/worker/nodemain.js index 7d7b04b6..a9b83c01 100644 --- a/src/worker/nodemain.js +++ b/src/worker/nodemain.js @@ -1,4 +1,6 @@ +// TODO: merge with workertestutils + var assert = require('assert'); var fs = require('fs'); var vm = require('vm'); @@ -69,6 +71,16 @@ if (require.main == module) { var msgs = JSON.parse(data); for (var i=0; i:(\d+):/i, /^\s*([0-9A-F]{4})/i); // parse symbol map var symbolmap = {}; @@ -1102,7 +1128,7 @@ function assembleXASM6809(code, platform) { return {errors:errors}; var aout = FS.readFile("main.bin", {encoding:'binary'}); // 00001 0000 [ 2] 1048 asld - var asmlines = parseListing(alst, /^\s*([0-9A-F]+)\s+([0-9A-F]+)\s+\[([0-9 ]+)\]\s+(\d+) (.*)/i, 1, 2, 4, params.code_offset); //, 5, 3); + var asmlines = parseListing(alst, /^\s*([0-9A-F]+)\s+([0-9A-F]+)\s+\[([0-9 ]+)\]\s+(\d+) (.*)/i, 1, 2, 4); return { output:aout, errors:errors, @@ -1179,7 +1205,7 @@ function assembleNAKEN(code, platform) { var alst = FS.readFile("out.lst", {encoding:'utf8'}); //console.log(alst); // 0x0000: 77 ld (hl),a cycles: 4 - var asmlines = parseListing(alst, /^0x([0-9a-f]+):\s+([0-9a-f]+)\s+(.+)cycles: (\d+)/i, 0, 1, 2); //, 3); + var asmlines = parseListing(alst, /^0x([0-9a-f]+):\s+([0-9a-f]+)\s+(.+)cycles: (\d+)/i, 0, 1, 2); return { output:aout, errors:errors, diff --git a/test/cli/testworker.js b/test/cli/testworker.js index e2931715..3d7cc6fe 100644 --- a/test/cli/testworker.js +++ b/test/cli/testworker.js @@ -4,6 +4,7 @@ var fs = require('fs'); var wtu = require('./workertestutils.js'); global.onmessage({data:{preload:'cc65', platform:'nes'}}); +global.onmessage({data:{preload:'ca65', platform:'nes'}}); global.onmessage({data:{preload:'sdcc'}}); // @@ -64,6 +65,9 @@ describe('Worker', function() { it('should NOT compile CC65', function(done) { compile('cc65', 'int main() {\nint x=1;\nprintf("%d",x);\nreturn x+2;\n}', 'nes-conio', done, 0, 0, 1); }); + it('should assemble CA65', function(done) { + compile('ca65', '\t.segment "HEADER"\n\t.segment "STARTUP"\n\t.segment "CHARS"\n\t.segment "VECTORS"\n\tlda #0\n\tsta $1\n', 'nes-conio', done, 40976, 2); + }); /* it('should assemble Z80ASM', function(done) { compile('z80asm', '\tMODULE test\n\tEXTERN _puts\n\tld hl,$0000\n\tret\n', 'mw8080bw', done, 4, 2, 0);