Download tools/sym.mjs from HelloSun/esp32emu: direct link, hf CLI and curl.
- Browser
- Download file 627 Bytes
-
https://huggingface.co/spaces/HelloSun/esp32emu/resolve/main/tools/sym.mjs
- Command line
-
hf download hf://spaces/HelloSun/esp32emu/tools/sym.mjs
-
curl -L -o sym.mjs https://huggingface.co/spaces/HelloSun/esp32emu/resolve/main/tools/sym.mjs
627 Bytes
| import fs from 'fs'; | |
| export class Syms { | |
| constructor(files) { this.a = []; for (const f of files) for (const l of fs.readFileSync(f, 'utf8').split('\n')) { const m = l.match(/^([0-9a-f]+) \w (.*)$/); if (m) this.a.push([parseInt(m[1], 16), m[2]]); } this.a.sort((x, y) => x[0] - y[0]); } | |
| name(addr) { addr >>>= 0; let lo = 0, hi = this.a.length - 1, best = -1; while (lo <= hi) { const mid = (lo + hi) >> 1; if (this.a[mid][0] <= addr) { best = mid; lo = mid + 1; } else hi = mid - 1; } if (best < 0) return '?'; const [a, n] = this.a[best]; if (addr - a > 0x4000) return '?'; return n + '+' + (addr - a).toString(16); } | |
| } | |