From 59469b41b82a05614ab583877d702bc0fb214087 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Tue, 28 Aug 2018 13:59:12 -0400 Subject: [PATCH] finished zmac asm (.z); fixed javatari submodule tag; upgraded tsc --- javatari.js | 2 +- package-lock.json | 6 ++--- package.json | 2 +- src/baseplatform.ts | 2 +- src/ui.ts | 3 ++- src/worker/workermain.js | 55 +++++++++++++++++++++++++++------------- 6 files changed, 45 insertions(+), 25 deletions(-) diff --git a/javatari.js b/javatari.js index 4cd5b798..bd17384f 160000 --- a/javatari.js +++ b/javatari.js @@ -1 +1 @@ -Subproject commit 4cd5b798f534336d09a80e8a1fa962959f401359 +Subproject commit bd17384fd2c6b020497e5e6a625a1b8130e39ea1 diff --git a/package-lock.json b/package-lock.json index 0725920b..433670fa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1018,9 +1018,9 @@ } }, "typescript": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", - "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.0.1.tgz", + "integrity": "sha512-zQIMOmC+372pC/CCVLqnQ0zSBiY7HHodU7mpQdjiZddek4GMj31I3dUJ7gAs9o65X7mnRma6OokOkc6f9jjfBg==", "dev": true }, "uuid": { diff --git a/package.json b/package.json index f13d3d52..093829c6 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "jsdom": "^12.0.0", "lzg": "^1.0.0", "mocha": "^5.2.0", - "typescript": "^2.9.2", + "typescript": "^3.0.1", "wavedrom-cli": "^0.5.0" }, "description": "8bitworkshop.com", diff --git a/src/baseplatform.ts b/src/baseplatform.ts index 3909b454..61231542 100644 --- a/src/baseplatform.ts +++ b/src/baseplatform.ts @@ -536,7 +536,7 @@ export function getToolForFilename_z80(fn) { if (fn.endsWith(".s")) return "sdasz80"; if (fn.endsWith(".ns")) return "naken"; if (fn.endsWith(".scc")) return "sccz80"; - if (fn.endsWith(".zmac")) return "zmac"; + if (fn.endsWith(".z")) return "zmac"; return "zmac"; } diff --git a/src/ui.ts b/src/ui.ts index 38de7ccf..18ac608b 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -44,7 +44,8 @@ var TOOL_TO_SOURCE_STYLE = { 'sdasz80': 'z80', 'sdcc': 'text/x-csrc', 'verilator': 'verilog', - 'jsasm': 'z80' + 'jsasm': 'z80', + 'zmac': 'z80', } function newWorker() : Worker { diff --git a/src/worker/workermain.js b/src/worker/workermain.js index 3f191774..b9fc6cdb 100644 --- a/src/worker/workermain.js +++ b/src/worker/workermain.js @@ -452,10 +452,12 @@ function extractErrors(regex, strings, path) { // TODO: "of" doesn't work in MSIE -function parseListing(code, lineMatch, iline, ioffset, iinsns, origin) { +var re_crlf = /\r?\n/; + +function parseListing(code, lineMatch, iline, ioffset, iinsns) { var lines = []; origin |= 0; - for (var line of code.split(/\r?\n/)) { + for (var line of code.split(re_crlf)) { var linem = lineMatch.exec(line); if (linem && linem[1]) { var linenum = parseInt(linem[iline]); @@ -477,7 +479,7 @@ function parseSourceLines(code, lineMatch, offsetMatch, origin) { var lines = []; var lastlinenum = 0; origin |= 0; - for (var line of code.split(/\r?\n/)) { + for (var line of code.split(re_crlf)) { var linem = lineMatch.exec(line); if (linem && linem[1]) { lastlinenum = parseInt(linem[1]); @@ -506,7 +508,7 @@ function parseDASMListing(code, unresolved, mainFilename) { var macrolines = []; var lastline = 0; var macros = {}; - for (var line of code.split(/\r?\n/)) { + for (var line of code.split(re_crlf)) { var linem = lineMatch.exec(line); if (linem && linem[1]) { var linenum = parseInt(linem[1]); @@ -669,7 +671,7 @@ function parseCA65Listing(code, symbols, params, dbg) { var insnLineMatch = /^([0-9A-F]+)([r]?)\s+(\d+)\s+([0-9A-F][0-9A-F ]*[0-9A-F])\s+/; var lines = []; var linenum = 0; - for (var line of code.split(/\r?\n/)) { + for (var line of code.split(re_crlf)) { linenum++; var segm = segLineMatch.exec(line); if (segm) { @@ -892,6 +894,7 @@ function parseIHX(ihx, rom_start, rom_size) { } } } + return output; } function assembleSDASZ80(step) { @@ -1361,12 +1364,13 @@ function compileYosys(step) { function assembleZMAC(step) { loadNative("zmac"); - var objout, lstout, symout; + var hexout, lstout; var errors = []; + var params = step.params; gatherFiles(step, {mainFilePath:"main.asm"}); - var binpath = "zout/" + step.prefix + ".cim"; - var lstpath = "zout/" + step.prefix + ".lst"; - if (staleFiles(step, [binpath, lstpath])) { + var hexpath = step.prefix + ".hex"; + var lstpath = step.prefix + ".lst"; + if (staleFiles(step, [hexpath, lstpath])) { /* error1.asm(4) : 'l18d4' Undeclared JP L18D4 @@ -1384,23 +1388,38 @@ error1.asm(11): warning: 'foobar' treated as label (instruction typo?) }); var FS = ZMAC['FS']; populateFiles(step, FS); - execMain(step, ZMAC, ['-z', '--oo', 'lst,cim', step.path]); + // TODO: don't know why CIM (hexary) doesn't work + execMain(step, ZMAC, ['-z', '--oo', 'lst,hex', step.path]); if (errors.length) { return {errors:errors}; } - objout = FS.readFile(binpath, {encoding:'utf8'}); - lstout = FS.readFile(lstpath, {encoding:'utf8'}); - putWorkFile(binpath, objout); + hexout = FS.readFile("zout/"+hexpath, {encoding:'utf8'}); + lstout = FS.readFile("zout/"+lstpath, {encoding:'utf8'}); + putWorkFile(hexpath, hexout); putWorkFile(lstpath, lstout); - // 230: 1739+7 017A 1600 L017A: LD D,00h - var listing = parseListing(lstout, /\s*(\d+):\s*(\d+)[+](\d+)\s+([0-9a-f]+)\s+([0-9a-f]+)\s+(.+)/i, 1, 4, 5); + if (!anyTargetChanged(step, [hexpath, lstpath])) + return; + // 230: 1739+7+x 017A 1600 L017A: LD D,00h + var lines = parseListing(lstout, /\s*(\d+):\s*([0-9+]+)\s+([0-9a-f]+)\s+([0-9a-f]+)\s+(.+)/i, 1, 3, 4); var listings = {}; - listings[lstpath] = listing; + listings[lstpath] = {lines:lines}; + // parse symbol table + var symbolmap = {}; + var sympos = lstout.indexOf('Symbol Table:'); + if (sympos > 0) { + var symout = lstout.slice(sympos+14); + symout.split('\n').forEach(function(l) { + var m = l.match(/(\S+)\s+([= ]*)([0-9a-f]+)/i); + if (m) { + symbolmap[m[1]] = parseInt(m[3],16); + } + }); + } return { - output:binpath, + output:parseIHX(hexout, params.rom_start||params.code_start, params.rom_size), listings:listings, errors:errors, - //symbolmap:symbolmap + symbolmap:symbolmap }; } }