mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-06-01 05:41:31 +00:00
dasm: fixed macro line parsing, breakpoints
This commit is contained in:
parent
4ccf588c80
commit
d97b0eb1c5
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "8bitworkshop",
|
"name": "8bitworkshop",
|
||||||
"version": "3.7.1",
|
"version": "3.7.2",
|
||||||
"author": "Steven Hugg",
|
"author": "Steven Hugg",
|
||||||
"description": "8bitworkshop.com",
|
"description": "8bitworkshop.com",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -7,7 +7,7 @@ deps.dot:
|
||||||
grep \`include *.v | sed "s/:/ /g" | awk '{ print "\"" $1 "\" -> " $3 ";" }'
|
grep \`include *.v | sed "s/:/ /g" | awk '{ print "\"" $1 "\" -> " $3 ";" }'
|
||||||
|
|
||||||
%.bin: %.v
|
%.bin: %.v
|
||||||
~/yosys/yosys -p "synth_ice40 -blif $*.blif" $*.v
|
yosys -p "synth_ice40 -blif $*.blif" $*.v
|
||||||
arachne-pnr -d 1k -p icestick.pcf $*.blif -o $*.asc
|
arachne-pnr -d 1k -p icestick.pcf $*.blif -o $*.asc
|
||||||
icepack $*.asc $*.bin
|
icepack $*.asc $*.bin
|
||||||
#iceprog $*.bin
|
#iceprog $*.bin
|
||||||
|
|
|
@ -31,8 +31,12 @@ export class SourceFile {
|
||||||
this.line2offset = new Map();
|
this.line2offset = new Map();
|
||||||
for (var info of lines) {
|
for (var info of lines) {
|
||||||
if (info.offset >= 0) {
|
if (info.offset >= 0) {
|
||||||
this.offset2loc[info.offset] = info;
|
// first line wins (is assigned to offset)
|
||||||
this.line2offset[info.line] = info.offset;
|
// TODO: handle macros/includes w/ multiple offsets per line
|
||||||
|
if (!this.offset2loc[info.offset])
|
||||||
|
this.offset2loc[info.offset] = info;
|
||||||
|
if (!this.line2offset[info.line])
|
||||||
|
this.line2offset[info.line] = info.offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,8 +384,8 @@ export class CodeProject {
|
||||||
// returns first listing in format [prefix].lst (TODO: could be better)
|
// returns first listing in format [prefix].lst (TODO: could be better)
|
||||||
getListingForFile(path: string) : CodeListing {
|
getListingForFile(path: string) : CodeListing {
|
||||||
// ignore include files (TODO)
|
// ignore include files (TODO)
|
||||||
if (path.toLowerCase().endsWith('.h') || path.toLowerCase().endsWith('.inc'))
|
//if (path.toLowerCase().endsWith('.h') || path.toLowerCase().endsWith('.inc'))
|
||||||
return;
|
//return;
|
||||||
var fnprefix = getFilenamePrefix(this.stripLocalPath(path));
|
var fnprefix = getFilenamePrefix(this.stripLocalPath(path));
|
||||||
var listings = this.getListings();
|
var listings = this.getListings();
|
||||||
var onlyfile = null;
|
var onlyfile = null;
|
||||||
|
|
|
@ -715,23 +715,35 @@ function parseSourceLines(code:string, lineMatch, offsetMatch) {
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseDASMListing(code:string, listings:CodeListingMap, errors:WorkerError[], unresolved:{}) {
|
function parseDASMListing(lstpath:string, lsttext:string, listings:CodeListingMap, 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+(\S+)?/i;
|
||||||
var lastline = 0;
|
var lastline = 0;
|
||||||
var macros = {};
|
var macros = {};
|
||||||
for (var line of code.split(re_crlf)) {
|
var lstline = 0;
|
||||||
var linem = lineMatch.exec(line);
|
var lstlist = listings[lstpath];
|
||||||
if (linem && linem[1]) {
|
for (var line of lsttext.split(re_crlf)) {
|
||||||
|
lstline++;
|
||||||
|
var linem = lineMatch.exec(line + " ");
|
||||||
|
if (linem && linem[1] != null) {
|
||||||
var linenum = parseInt(linem[1]);
|
var linenum = parseInt(linem[1]);
|
||||||
var filename = linem[2];
|
var filename = linem[2];
|
||||||
var offset = parseInt(linem[3], 16);
|
var offset = parseInt(linem[3], 16);
|
||||||
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;
|
||||||
|
// don't use listing yet
|
||||||
|
if (lstlist && lstlist.lines) {
|
||||||
|
lstlist.lines.push({
|
||||||
|
line:lstline,
|
||||||
|
offset:offset,
|
||||||
|
insns:insns,
|
||||||
|
iscode:true,
|
||||||
|
});
|
||||||
|
}
|
||||||
// inside of a file?
|
// inside of a file?
|
||||||
var lst = listings[filename];
|
var lst = listings[filename];
|
||||||
if (lst) {
|
if (lst) {
|
||||||
|
@ -753,16 +765,26 @@ function parseDASMListing(code:string, listings:CodeListingMap, errors:WorkerErr
|
||||||
} else {
|
} else {
|
||||||
// inside of macro?
|
// inside of macro?
|
||||||
var mac = macros[filename.toLowerCase()];
|
var mac = macros[filename.toLowerCase()];
|
||||||
if (insns && mac) {
|
// macro invocation in main file
|
||||||
/*
|
if (mac && linenum == 0) {
|
||||||
lines.push({
|
lines.push({
|
||||||
path:mac.file,
|
line:lastline+1,
|
||||||
line:mac.line+linenum,
|
|
||||||
offset:offset,
|
offset:offset,
|
||||||
insns:insns,
|
insns:insns,
|
||||||
iscode:true
|
iscode:true
|
||||||
});
|
});
|
||||||
*/
|
}
|
||||||
|
if (insns && mac) {
|
||||||
|
var maclst = listings[mac.file];
|
||||||
|
if (maclst && maclst.lines) {
|
||||||
|
maclst.lines.push({
|
||||||
|
path:mac.file,
|
||||||
|
line:mac.line+linenum,
|
||||||
|
offset:offset,
|
||||||
|
insns:insns,
|
||||||
|
iscode:true
|
||||||
|
});
|
||||||
|
}
|
||||||
// TODO: a listing file can't include other files
|
// TODO: a listing file can't include other files
|
||||||
} else {
|
} else {
|
||||||
// inside of macro or include file
|
// inside of macro or include file
|
||||||
|
@ -846,10 +868,11 @@ function assembleDASM(step:BuildStep) {
|
||||||
var alst = FS.readFile(lstpath, {'encoding':'utf8'});
|
var alst = FS.readFile(lstpath, {'encoding':'utf8'});
|
||||||
// parse main listing, get errors and listings for each file
|
// parse main listing, get errors and listings for each file
|
||||||
var listings : CodeListingMap = {};
|
var listings : CodeListingMap = {};
|
||||||
|
//listings[lstpath] = {lines:[], text:alst};
|
||||||
for (let path of step.files) {
|
for (let path of step.files) {
|
||||||
listings[path] = {lines:[]};
|
listings[path] = {lines:[]};
|
||||||
}
|
}
|
||||||
parseDASMListing(alst, listings, errors, unresolved);
|
parseDASMListing(lstpath, alst, listings, errors, unresolved);
|
||||||
if (errors.length) {
|
if (errors.length) {
|
||||||
return {errors:errors};
|
return {errors:errors};
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,10 +82,10 @@ function doBuild(msgs, callback, outlen, nlines, nerrors, options) {
|
||||||
|
|
||||||
describe('Worker', function() {
|
describe('Worker', function() {
|
||||||
it('should assemble DASM', function(done) {
|
it('should assemble DASM', function(done) {
|
||||||
compile('dasm', '\tprocessor 6502\n\torg $f000\nfoo lda #0\n', 'vcs.mame', done, 2, 1);
|
compile('dasm', '\tprocessor 6502\n\torg $f000\n MAC mack\n lda #0\n ENDM\nfoo: mack\n mack\n', 'vcs.mame', done, 4, 4);
|
||||||
});
|
});
|
||||||
it('should NOT assemble DASM', function(done) {
|
it('should NOT assemble DASM', function(done) {
|
||||||
compile('dasm', '\tprocessor 6502\n\torg $f000 ; this is a comment\nfoo asl a\n', 'vcs', done, 0, 0, 1);
|
compile('dasm', '\tprocessor 6502\n\torg $f000 ; this is a comment\nfoo asl a\n', 'vcs', done, 0, 0, 2);
|
||||||
});
|
});
|
||||||
/*
|
/*
|
||||||
it('should assemble ACME', function(done) {
|
it('should assemble ACME', function(done) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user