Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 5x 5x 5x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 343x 343x 343x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 5x 5x 2724x 2719x 2719x 2719x 1974x 1974x 1974x 2719x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2474x 2474x 2474x 2474x 112x 112x 2474x 2474x 177x 177x 177x 2474x 2474x 2x 2x 2474x 2474x 2474x 2474x 2474x 2474x 2474x 2474x 2474x 1689x 1689x 1689x 1689x 1689x 1689x 1689x 1689x 1689x 1x 1x 1x 10x 10x 1x 1x 1x 1689x 1689x 1689x 2026x 2026x 2026x 1689x 1689x 1689x 1689x 1689x 2474x 2724x 2724x 2724x 1444x 1444x 1444x 1444x 209x 209x 1444x 1444x 1444x 2724x 2724x 2724x 2724x 2724x 2x 2x 2724x 2x 2x 2x 2x 2x 2724x 5x 5x 2724x 5x 5x 2724x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 2710x 2724x 6x 6x 6x 2724x 6x 6x 6x 2724x 9x 9x 9x 2724x 6x 6x 6x 2724x 6x 6x 6x 2724x 6x 6x 6x 2724x 6x 6x 6x 2724x 6x 6x 6x 2724x 33x 33x 33x 2724x 9x 9x 9x 2724x 6x 6x 6x 2724x 6x 6x 6x 2724x 6x 6x 6x 2599x 2724x 6x 6x 6x 2593x 2724x 4x 4x 4x 2589x 2724x 14x 14x 14x 2575x 2724x 14x 14x 14x 2724x 17x 17x 17x 2544x 2724x 14x 14x 14x 14x 2530x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2434x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2407x 2724x 2724x 2724x 2724x 2395x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2359x 2724x 2724x 2724x 2724x 2333x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 2724x 480x 480x 2050x 2050x 2724x 2724x 2724x 2724x 2724x 2x 2x 2x 2048x 2724x 30x 30x 2018x 2018x 2018x 2724x 2x 2x 2x 2x 2x 2016x 2724x 825x 2724x 52x 52x 52x 773x 773x 773x 2724x 770x 770x 770x 770x 770x 770x 770x 770x 709x 709x 770x 770x 1x 1x 1x 60x 770x 60x 60x 60x 770x 60x 770x 60x 60x 60x 770x 58x 58x 3x 2724x 2x 2x 2x 1x 1x 1x 1x 1x | import { btoax, atobx } from "./utils/base64escaped.js";
import { Parser } from "./expression-parser.js";
/**
* Vrátí číslo řádku včetně informace o includovaném souboru
* @param {Object} s - Řádek s případnými atributy includedFile a numline
* @returns {string|number} Číslo řádku nebo kombinace soubor/řádek
*/
const includedLineNumber = (s) => {
if (!s.includedFile) return s.numline;
return s.includedFileAtLine + "__" + s.numline;
}
/**
* Parsuje jeden řádek assemblerového zdrojového kódu do tokenizované struktury
* @param {Object} s - Objekt s atributem line (řetězec řádku) a dalšími metadaty
* @param {Object} macros - Objekt s definovanými makry
* @param {Object} opts - Možnosti assembleru (stopFlag, olds, assembler, ...)
* @returns {Object} Tokenizovaný řádek s rozpoznanými poli (label, opcode, params, ...)
* @throws {Object} Pokud dojde k chybě v syntaxi nebo neznámé instrukci
*/
export const parseLine = (s, macros, opts = {stopFlag:null, olds:null, assembler:null}) => {
let t = s.line;
let ll;
//anonymous labels
//format: : label
ll = t.match(/^\s*:\s*(.*)/);
if (ll) {
s.anonymousLabel = "anon__" + includedLineNumber(s);
t = ll[1];
}
//console.log(s, ll)
//labels
//format: label:
ll = t.match(/^\s*(\@{0,1}[a-zA-Z0-9-_]+):\s*(.*)/);
//console.log(t, ll)
if (ll) {
s.label = ll[1].toUpperCase();
t = ll[2];
}
//anonymous labels
//format: : label
ll = t.match(/^\s*:\s*(.*)/);
//console.log(s, ll)
if (ll) {
s.label = "__@anon" + s.numline;
t = ll[2];
}
s._dp = 0;
s.params = [];
//special EQU format as "label = value"
let oo = t.match(/^\s*(\=)\s*(.*)/);
if (oo) {
s.opcode = oo[1].toUpperCase();
t = oo[2];
} else {
oo = t.match(/^\s*([\.a-zA-Z0-9-_]+)\s*(.*)/);
//console.log("2",oo,t)
if (oo) {
s.opcode = oo[1].toUpperCase();
t = oo[2];
}
}
/*
oo = t.match(/^\s*(:\=)\s*(.*)/);
if (oo) {
s.opcode = "=";
t = oo[2];
}
*/
if (t) {
//param grouping by {}
//try {
//console.log(t)
while (t.match(/\"(.*?)\"/g)) {
t = t.replace(/\"(.*?)\"/g, (n) => "00ss" + btoax(n) + "!");
}
while (t.match(/\'(.*?)\'/g)) {
//console.log(t)
t = t.replace(/\'(.*?)\'/g, (n) => "00ss" + btoax('"' + n.substr(1, n.length - 2) + '"') + "!");
}
while (t.match(/\{(.*?)\}/g)) {
t = t.replace(/\{(.*?)\}/g, (n) => "00bb" + btoax(n.substr(1, n.length - 2)));
}
//} catch(e) {
// console.log(e,t)
//}
//semicolon fix
while (t.match(/"(.*?);(.*?)"/g)) {
t = t.replace(/"(.*?);(.*?)"/g, '"$1§$2"');
}
while (t.match(/'(.*?);(.*?)'/g)) {
t = t.replace(/'(.*?);(.*?)'/g, '"$1§$2"');
}
let pp = t.match(/^\s*([^;]*)(.*)/);
if (pp && pp[1].length) {
s.paramstring = pp[1];
//sane strings
let ppc = pp[1];
while (ppc.match(/"(.*?),(.*?)"/g)) {
ppc = ppc.replace(/"(.*?),(.*?)"/g, '"$1€$2"');
}
while (ppc.match(/'(.*?),(.*?)'/g)) {
ppc = ppc.replace(/'(.*?),(.*?)'/g, '"$1€$2"');
}
let n = ppc.match(/([0-9]+)\s*DUP\s*\((.*)\)/i);
if (n) {
let dup = parseInt(n[1]);
let nln = "";
for (let i = 0; i < dup; i++) {
nln += n[2] + ",";
}
ppc = nln.substring(0, nln.length - 1);
//console.log(ppc);
}
let px = ppc.split(/\s*,\s*/);
s.params = px.map((ppc) => {
let p = (ppc.replace(/€/g, ",").replace(/§/g, ";")).trim();
p = p.replace(/00ss(.*?)\!/g, (n) => atobx(n.substr(4, n.length - 5)));
return p;
});
//console.log(s)
t = pp[2].replace(/§/g, ";");
}
}
//console.log("SSS",s)
if (t) {
let rr = t.match(/^\s*;*(.*)/);
if (rr) {
s.remark = rr[1].replace(/00ss(.*?)\!/g, (n) => atobx(n.substr(4, n.length - 5)));
if (!s.remark) {
s.remark = " ";
}
t = "";
}
}
s.notparsed = t;
//pokus s opts
//console.log("ZDECH", s)
if (s.opcode === "ORG") {
s.opcode = ".ORG";
}
if (s.opcode === ".ERROR") {
s.paramstring = s.paramstring.replace(/00ss(.*?)\!/g, (n) => atobx(n.substr(4, n.length - 5)));
return s;
//console.log(stopFlag,olds,vars)
//throw { "msg": s.paramstring.replace(/00ss(.*?)\!/g, function (n) { return atobx(n.substr(4, n.length - 5)) }), "s":s};
}
if (s.opcode === ".EQU") {
s.opcode = "EQU";
}
if (s.opcode === ".FILL") {
s.opcode = "FILL";
}
if (s.opcode === ".ORG") {
return s;
// obsolete - evaluate origin has been suppressed
/*
try {
// s.addr = Parser.evaluate(s.paramstring);
return s;
} catch (e) {
throw {
msg: e.msg,
s: s
};
}
*/
}
if (s.opcode === "DEFB") {
s.opcode = "DB";
return s;
}
if (s.opcode === ".BYTE") {
s.opcode = "DB";
return s;
}
if (s.opcode === ".DB") {
s.opcode = "DB";
return s;
}
if (s.opcode === ".WORD") {
s.opcode = "DW";
return s;
}
if (s.opcode === ".DW") {
s.opcode = "DW";
return s;
}
if (s.opcode === "DEFW") {
s.opcode = "DW";
return s;
}
if (s.opcode === ".DD") {
s.opcode = "DD";
return s;
}
if (s.opcode === ".DF") {
s.opcode = "DF";
return s;
}
if (s.opcode === ".DFZXS") {
s.opcode = "DFZXS";
return s;
}
if (s.opcode === ".DFF") {
s.opcode = "DFF";
return s;
}
if (s.opcode === "DEFS") {
s.opcode = "DS";
return s;
}
if (s.opcode === ".RES") {
s.opcode = "DS";
return s;
}
if (s.opcode === "DEFM") {
s.opcode = "DS";
return s;
}
if (s.opcode === ".ALIGN") {
s.opcode = "ALIGN";
return s;
}
if (s.opcode === ".IFN") {
s.opcode = "IFN";
return s;
}
if (s.opcode === ".IF") {
s.opcode = "IF";
return s;
}
if (s.opcode === ".ELSE") {
s.opcode = "ELSE";
return s;
}
if (s.opcode === ".ENDIF") {
s.opcode = "ENDIF";
return s;
}
if (s.opcode === ".PRAGMA") {
opts.PRAGMAS = opts.PRAGMAS || [];
opts.PRAGMAS.push(s.params[0].toUpperCase());
return s;
}
if (s.opcode === "EQU" ||
s.opcode === "=" ||
s.opcode === ".SET" ||
s.opcode === "IF" ||
s.opcode === "IFN" ||
s.opcode === "ELSE" ||
s.opcode === "ENDIF" ||
s.opcode === ".ERROR" ||
s.opcode === ".INCLUDE" ||
s.opcode === ".INCBIN" ||
s.opcode === ".MACRO" ||
s.opcode === ".ENDM" ||
s.opcode === ".BLOCK" ||
s.opcode === ".ENDBLOCK" ||
s.opcode === ".REPT" ||
s.opcode === ".CPU" ||
s.opcode === ".ENT" ||
s.opcode === ".BINFROM" ||
s.opcode === ".BINTO" ||
s.opcode === ".ENGINE" ||
s.opcode === ".PRAGMA" ||
s.opcode === "END" ||
s.opcode === ".END" ||
//6809 assembler ops
s.opcode === "BSZ" ||
s.opcode === "FCB" ||
s.opcode === "FCC" ||
s.opcode === "FDB" ||
s.opcode === "FILL" ||
s.opcode === "RMB" ||
s.opcode === "ZMB" ||
s.opcode === "SETDP" ||
//65816
s.opcode === ".M8" ||
s.opcode === ".X8" ||
s.opcode === ".M16" ||
s.opcode === ".X16" ||
//phase, dephase
s.opcode === ".PHASE" ||
s.opcode === ".DEPHASE" ||
s.opcode === ".SETPHASE" ||
s.opcode === "ALIGN" ||
s.opcode === ".CSTR" ||
s.opcode === ".ISTR" ||
s.opcode === ".PSTR" ||
//segments
s.opcode === ".CSEG" ||
s.opcode === ".DSEG" ||
s.opcode === ".ESEG" ||
s.opcode === ".BSSEG" ||
//modules
s.opcode === ".EXPORT" ||
s.opcode === ".EXTERN" ||
s.opcode === "DB" ||
s.opcode === "DW" ||
s.opcode === "DD" ||
s.opcode === "DF" ||
s.opcode === "DFF" ||
s.opcode === "DFZXS" ||
s.opcode === "DS") {
return s;
}
if (s.opcode === ".DEBUGINFO" ||
s.opcode === ".MACPACK" ||
s.opcode === ".FEATURE" ||
s.opcode === ".ZEROPAGE" ||
s.opcode === ".SEGMENT" ||
s.opcode === ".SETCPU") {
s.opcode = "";
return s;
}
if (!s.opcode && s.label) {
return s;
}
let ax = null
try {
ax = opts.assembler.parseOpcode(s, {}, Parser);
} catch (e) {
throw {
msg: e,
s: s
};
}
//console.log("SS",JSON.stringify(s),ax)
if (ax !== null) return ax;
if (macros[s.opcode]) {
s.macro = s.opcode;
return s;
}
//label bez dvojtecky
//console.log(s,s2)
if (!s.label && !opts.stopFlag) {
//console.log(s)
//let s2 = {line:s.line,numline:s.numline, addr:null,bytes:0};
let s2 = JSON.parse(JSON.stringify(s));
s2.addr = null;
s2.bytes = 0;
s2.oldline = s.line;
if (s.remark && !s.opcode) {
return s;
}
if (!s.params || s.params.length === 0)
throw {
msg: "Unrecognized instruction " + s.opcode,
s: s
};
if (!s.opcode)
throw {
msg: "Unrecognized instruction " + s.opcode,
s: s
};
//hotfix
//console.log(s)
if (s.params[0].indexOf(":=") === 0)
s.params[0] = ".SET" + s.params[0].substr(2);
s2.line = s.opcode + ": " + s.params.join();
if (s.remark) s2.line += " ;" + s.remark;
//console.log("ATTEMPT2",s2.line)
let sx = parseLine(s2, macros, {stopFlag:true, olds:s, ...opts});
if (!sx.opcode)
throw {
msg: "Unrecognized instruction " + s.opcode,
s: s
};
return sx;
}
if (opts.stopFlag)
throw {
msg: "Unrecognized instruction " + opts.olds.opcode,
s: s
};
throw {
msg: "Unrecognized instruction " + s.opcode,
s: s
};
}; |