mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-12-23 18:31:08 +00:00
fixed lookupSymbol()
This commit is contained in:
parent
1d1512453d
commit
dfbb5e0f47
@ -1,5 +1,5 @@
|
||||
|
||||
import { RAM, RasterVideo, dumpRAM, lookupSymbol } from "./emu";
|
||||
import { RAM, RasterVideo, dumpRAM } from "./emu";
|
||||
import { hex, printFlags, invertMap } from "./util";
|
||||
import { CodeAnalyzer } from "./analysis";
|
||||
import { disassemble6502 } from "./cpu/disasm6502";
|
||||
@ -932,7 +932,7 @@ export function dumpStackToString(platform:Platform, mem:Uint8Array|number[], st
|
||||
var opcode = read(addr + jsrofs); // might be out of bounds
|
||||
if (opcode == jsrop) { // JSR
|
||||
s += "\n$" + hex(sp) + ": ";
|
||||
s += hex(addr,4) + " " + lookupSymbol(addr);
|
||||
s += hex(addr,4) + " " + lookupSymbol(platform, addr);
|
||||
sp++;
|
||||
nraw = 0;
|
||||
} else {
|
||||
@ -944,3 +944,20 @@ export function dumpStackToString(platform:Platform, mem:Uint8Array|number[], st
|
||||
}
|
||||
return s+"\n";
|
||||
}
|
||||
|
||||
export function lookupSymbol(platform:Platform, addr:number) {
|
||||
var start = addr;
|
||||
var foundsym;
|
||||
var addr2symbol = platform.debugSymbols && platform.debugSymbols.addr2symbol;
|
||||
while (addr2symbol && addr >= 0) {
|
||||
var sym = addr2symbol[addr];
|
||||
if (sym && sym.startsWith('_')) { // return first C symbol we find
|
||||
return addr2symbol[addr] + " + " + (start-addr);
|
||||
} else if (sym && !foundsym) { // cache first non-C symbol found
|
||||
foundsym = sym;
|
||||
}
|
||||
addr--;
|
||||
}
|
||||
return foundsym || "";
|
||||
}
|
||||
|
||||
|
19
src/emu.ts
19
src/emu.ts
@ -445,22 +445,3 @@ export function newAddressDecoder(table : AddressDecoderEntry[], options?:Addres
|
||||
return new (AddressDecoder as any)(table, options);
|
||||
}
|
||||
|
||||
// STACK DUMP
|
||||
|
||||
var addr2symbol = {}; // address to symbol name map (TODO: import)
|
||||
|
||||
export function lookupSymbol(addr) {
|
||||
var start = addr;
|
||||
var foundsym;
|
||||
while (addr2symbol && addr >= 0) {
|
||||
var sym = addr2symbol[addr];
|
||||
if (sym && sym.startsWith('_')) { // return first C symbol we find
|
||||
return addr2symbol[addr] + " + " + (start-addr);
|
||||
} else if (sym && !foundsym) { // cache first non-C symbol found
|
||||
foundsym = sym;
|
||||
}
|
||||
addr--;
|
||||
}
|
||||
return foundsym || "";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user