mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-02-16 17:30:27 +00:00
DASM: more efficient parsing of multiple files, better unresolved symbol detection
This commit is contained in:
parent
31bd21ff87
commit
075de8aa77
@ -59,7 +59,6 @@ TODO:
|
|||||||
- error showing replay div before rom starts
|
- error showing replay div before rom starts
|
||||||
- compiler flags for final ROM build
|
- compiler flags for final ROM build
|
||||||
- workermain: split build functions, better msg types
|
- workermain: split build functions, better msg types
|
||||||
- vcs: INPTx needs to be added to control state
|
|
||||||
- sdcc: can't link asm files before c files (e.g. acheader.s must be last)
|
- sdcc: can't link asm files before c files (e.g. acheader.s must be last)
|
||||||
- what if >1 file with same name? (local/nonlocal/directory)
|
- what if >1 file with same name? (local/nonlocal/directory)
|
||||||
- what if .c and .s names collide?
|
- what if .c and .s names collide?
|
||||||
@ -77,7 +76,6 @@ TODO:
|
|||||||
- https://makecode.com/language?
|
- https://makecode.com/language?
|
||||||
- open ROM from URL?
|
- open ROM from URL?
|
||||||
- game starts even if switched away before first load
|
- game starts even if switched away before first load
|
||||||
- vcs: break on # of lines changed (maybe using getRasterPosition?)
|
|
||||||
- profiler restarts when paused
|
- profiler restarts when paused
|
||||||
- it's pretty easy to add a new file named like a library file (bcd.c)
|
- it's pretty easy to add a new file named like a library file (bcd.c)
|
||||||
- or have neslib.h in a subdirectory...
|
- or have neslib.h in a subdirectory...
|
||||||
@ -129,10 +127,13 @@ TODO:
|
|||||||
- replay doesn't work for nes (force background tile redraw)
|
- replay doesn't work for nes (force background tile redraw)
|
||||||
- nes debug view toolbar
|
- nes debug view toolbar
|
||||||
- support NES_HEADER_16K?
|
- support NES_HEADER_16K?
|
||||||
- vcs sound continues when paused
|
- vcs
|
||||||
|
- vcs sound continues when paused
|
||||||
|
- vcs: INPTx needs to be added to control state
|
||||||
|
- vcs: break on # of lines changed (maybe using getRasterPosition?)
|
||||||
|
- chrome looks blurry on vcs
|
||||||
- upload multiple files/zip file to subdirectory
|
- upload multiple files/zip file to subdirectory
|
||||||
- allow "include graphics.asm" instead of "include project/graphics.asm"
|
- allow "include graphics.asm" instead of "include project/graphics.asm"
|
||||||
- chrome looks blurry on vcs
|
|
||||||
- convert more stuff to Promises
|
- convert more stuff to Promises
|
||||||
- target ES6
|
- target ES6
|
||||||
- don't have to include bootstrap-tourist each time?
|
- don't have to include bootstrap-tourist each time?
|
||||||
|
@ -608,7 +608,7 @@ export class MemoryView implements ProjectView {
|
|||||||
for (var i=n1; i<n2; i++) {
|
for (var i=n1; i<n2; i++) {
|
||||||
var read = this.readAddress(offset+i);
|
var read = this.readAddress(offset+i);
|
||||||
if (i==8) s += ' ';
|
if (i==8) s += ' ';
|
||||||
s += ' ' + (read!==null?hex(read,2):'??');
|
s += ' ' + (typeof read == 'number' ? hex(read,2) : '??');
|
||||||
}
|
}
|
||||||
for (var i=n2; i<16; i++) s += ' ';
|
for (var i=n2; i<16; i++) s += ' ';
|
||||||
if (sym) s += ' ' + sym;
|
if (sym) s += ' ' + sym;
|
||||||
|
@ -644,14 +644,12 @@ function parseSourceLines(code:string, lineMatch, offsetMatch) {
|
|||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseDASMListing(code:string, unresolved:{}, mainFilename:string) {
|
function parseDASMListing(code:string, listings:{}, errors:WorkerError[], unresolved:{}) {
|
||||||
// TODO: this gets very slow
|
// TODO: this gets very slow
|
||||||
// 4 08ee a9 00 start lda #01workermain.js:23:5
|
// 4 08ee a9 00 start lda #01workermain.js:23:5
|
||||||
var lineMatch = /\s*(\d+)\s+(\S+)\s+([0-9a-f]+)\s+([?0-9a-f][?0-9a-f ]+)?\s+(.+)?/i;
|
var lineMatch = /\s*(\d+)\s+(\S+)\s+([0-9a-f]+)\s+([?0-9a-f][?0-9a-f ]+)?\s+(.+)?/i;
|
||||||
var equMatch = /\bequ\b/i;
|
var equMatch = /\bequ\b/i;
|
||||||
var macroMatch = /\bMAC\s+(.+)?/i;
|
var macroMatch = /\bMAC\s+(.+)?/i;
|
||||||
var errors = [];
|
|
||||||
var lines = [];
|
|
||||||
var macrolines = [];
|
var macrolines = [];
|
||||||
var lastline = 0;
|
var lastline = 0;
|
||||||
var macros = {};
|
var macros = {};
|
||||||
@ -664,8 +662,10 @@ function parseDASMListing(code:string, unresolved:{}, mainFilename:string) {
|
|||||||
var insns = linem[4];
|
var insns = linem[4];
|
||||||
var restline = linem[5];
|
var restline = linem[5];
|
||||||
if (insns && insns.startsWith('?')) insns = null;
|
if (insns && insns.startsWith('?')) insns = null;
|
||||||
// inside of main file?
|
// inside of a file?
|
||||||
if (filename == mainFilename) {
|
var lst = listings[filename];
|
||||||
|
if (lst) {
|
||||||
|
var lines = lst.lines;
|
||||||
// look for MAC statement
|
// look for MAC statement
|
||||||
var macmatch = macroMatch.exec(restline);
|
var macmatch = macroMatch.exec(restline);
|
||||||
if (macmatch) {
|
if (macmatch) {
|
||||||
@ -708,11 +708,14 @@ function parseDASMListing(code:string, unresolved:{}, mainFilename:string) {
|
|||||||
if (pos >= 0) {
|
if (pos >= 0) {
|
||||||
var cmt = l.indexOf(';');
|
var cmt = l.indexOf(';');
|
||||||
if (cmt < 0 || cmt > pos) {
|
if (cmt < 0 || cmt > pos) {
|
||||||
errors.push({
|
// make sure identifier is flanked by non-word chars
|
||||||
path:filename,
|
if (/\w+/.test(key) && new RegExp("\\b"+key+"\\b").test(key)) {
|
||||||
line:linenum,
|
errors.push({
|
||||||
msg:"Unresolved symbol '" + key + "'"
|
path:filename,
|
||||||
});
|
line:linenum,
|
||||||
|
msg:"Unresolved symbol '" + key + "'"
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -727,8 +730,6 @@ function parseDASMListing(code:string, unresolved:{}, mainFilename:string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: use macrolines
|
// TODO: use macrolines
|
||||||
// TODO: return {text:code, asmlines:lines, macrolines:macrolines, errors:errors};
|
|
||||||
return {lines:lines, macrolines:macrolines, errors:errors};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function assembleDASM(step:BuildStep) {
|
function assembleDASM(step:BuildStep) {
|
||||||
@ -768,22 +769,13 @@ function assembleDASM(step:BuildStep) {
|
|||||||
"-o"+binpath,
|
"-o"+binpath,
|
||||||
"-s"+sympath ]);
|
"-s"+sympath ]);
|
||||||
var alst = FS.readFile(lstpath, {'encoding':'utf8'});
|
var alst = FS.readFile(lstpath, {'encoding':'utf8'});
|
||||||
// parse main listing, get errors
|
// parse main listing, get errors and listings for each file
|
||||||
var listing = parseDASMListing(alst, unresolved, step.path);
|
|
||||||
errors = errors.concat(listing.errors);
|
|
||||||
if (errors.length) {
|
|
||||||
return {errors:errors};
|
|
||||||
}
|
|
||||||
var listings = {};
|
var listings = {};
|
||||||
listings[lstpath] = listing;
|
for (let path of step.files) {
|
||||||
// parse include files
|
listings[path] = {lines:[]};
|
||||||
// TODO: kinda wasted effort
|
|
||||||
for (var fn of step.files) {
|
|
||||||
if (fn != step.path) {
|
|
||||||
var lst = parseDASMListing(alst, unresolved, fn);
|
|
||||||
listings[fn] = lst; // TODO: foo.asm.lst
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
parseDASMListing(alst, listings, errors, unresolved);
|
||||||
|
// read binary rom output and symbols
|
||||||
var aout, asym;
|
var aout, asym;
|
||||||
aout = FS.readFile(binpath);
|
aout = FS.readFile(binpath);
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user