mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-29 14:51:17 +00:00
fixed cc65/ca65 hex offsets to key off symbol names, not segments
This commit is contained in:
parent
5ba5fe830b
commit
b131a45c5b
@ -131,7 +131,6 @@ TODO:
|
|||||||
- 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
|
- chrome looks blurry on vcs
|
||||||
- debug source lines are out of whack when >1 code segment
|
|
||||||
|
|
||||||
|
|
||||||
WEB WORKER FORMAT
|
WEB WORKER FORMAT
|
||||||
|
@ -834,32 +834,37 @@ function setupStdin(fs, code:string) {
|
|||||||
*/
|
*/
|
||||||
function parseCA65Listing(code, symbols, params, dbg) {
|
function parseCA65Listing(code, symbols, params, dbg) {
|
||||||
var segofs = 0;
|
var segofs = 0;
|
||||||
// .dbg line, "main.c", 1
|
var offset = 0;
|
||||||
var segLineMatch = /[.]segment\s+"(\w+)"/;
|
var dbgLineMatch = /^([0-9A-F]+)([r]?)\s+(\d+)\s+[.]dbg\s+(\w+), "([^"]+)", (.+)/;
|
||||||
//var dbgLineMatch = /^([0-9A-F]+)([r]?)\s+(\d+)\s+[.]dbg\s+line,\s+\S+,\s+(\d+)/;
|
var funcLineMatch = /"(\w+)", (\w+), "(\w+)"/;
|
||||||
var dbgLineMatch = /^([0-9A-F]+)([r]?)\s+(\d+)\s+[.]dbg\s+line,\s+"([^"]+)", (\d+)/;
|
|
||||||
var insnLineMatch = /^([0-9A-F]+)([r]?)\s+(\d+)\s+([0-9A-Fr ]*)\s*(.*)/;
|
var insnLineMatch = /^([0-9A-F]+)([r]?)\s+(\d+)\s+([0-9A-Fr ]*)\s*(.*)/;
|
||||||
var lines = [];
|
var lines = [];
|
||||||
var linenum = 0;
|
var linenum = 0;
|
||||||
|
// TODO: only does .c functions, not all .s files
|
||||||
for (var line of code.split(re_crlf)) {
|
for (var line of code.split(re_crlf)) {
|
||||||
// TODO: not right when multiple .segment directives
|
|
||||||
var segm = segLineMatch.exec(line);
|
|
||||||
if (segm) {
|
|
||||||
var segname = segm[1];
|
|
||||||
var segsym = '__'+segname+'_RUN__';
|
|
||||||
segofs = parseInt(symbols[segsym] || params[segsym]) || 0;
|
|
||||||
}
|
|
||||||
if (dbg) {
|
if (dbg) {
|
||||||
var dbgm = dbgLineMatch.exec(line);
|
var dbgm = dbgLineMatch.exec(line);
|
||||||
if (dbgm && dbgm[1]) {
|
if (dbgm && dbgm[1]) {
|
||||||
var offset = parseInt(dbgm[1], 16);
|
var dbgtype = dbgm[4];
|
||||||
|
offset = parseInt(dbgm[1], 16);
|
||||||
|
if (dbgtype == 'line') {
|
||||||
lines.push({
|
lines.push({
|
||||||
// TODO: sourcefile
|
// TODO: sourcefile
|
||||||
line:parseInt(dbgm[5]),
|
line:parseInt(dbgm[6]),
|
||||||
offset:offset + segofs,
|
offset:offset + segofs,
|
||||||
insns:null
|
insns:null
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else if (dbgtype == 'func') {
|
||||||
|
var funcm = funcLineMatch.exec(dbgm[6]);
|
||||||
|
if (funcm) {
|
||||||
|
var funcofs = symbols[funcm[3]];
|
||||||
|
if (typeof funcofs === 'number') {
|
||||||
|
segofs = funcofs - offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
var linem = insnLineMatch.exec(line);
|
var linem = insnLineMatch.exec(line);
|
||||||
if (linem) linenum++;
|
if (linem) linenum++;
|
||||||
@ -874,6 +879,16 @@ function parseCA65Listing(code, symbols, params, dbg) {
|
|||||||
});
|
});
|
||||||
// take back one to honor the long .byte line
|
// take back one to honor the long .byte line
|
||||||
if (linem[5].length == 0) linenum--;
|
if (linem[5].length == 0) linenum--;
|
||||||
|
} else {
|
||||||
|
var sym = linem[5];
|
||||||
|
if (sym && sym.endsWith(':')) {
|
||||||
|
sym = sym.substring(0, sym.length-1);
|
||||||
|
var symofs = symbols[sym];
|
||||||
|
if (typeof symofs === 'number') {
|
||||||
|
offset = parseInt(linem[1], 16);
|
||||||
|
segofs = symofs - offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user