mirror of
https://github.com/KrisKennaway/ii-vision.git
synced 2024-12-30 15:29:26 +00:00
c139e8bf1b
Add explicit end_{opcode} labels to mark (1 byte past) end of opcode. Rename op_done to op_terminate to match opcode name in encoder. Extract symbol table in encoder and use this to populate the opcode start/end addresses.
32 lines
745 B
Python
32 lines
745 B
Python
from typing import Dict
|
|
|
|
|
|
class SymbolTable:
|
|
"""Parse cc65 debug file to extract symbol table."""
|
|
|
|
def __init__(self, debugfile: str = None):
|
|
self.debugfile = debugfile
|
|
|
|
def parse(self, iostream=None) -> Dict:
|
|
syms = {}
|
|
|
|
if not iostream:
|
|
iostream = open(self.debugfile, "r")
|
|
|
|
with iostream as f:
|
|
for line in f.read().split("\n"):
|
|
if not line.startswith("sym"):
|
|
continue
|
|
|
|
sym = {}
|
|
data = line.split()[1].split(",")
|
|
for kv in data:
|
|
k, v = kv.split("=")
|
|
sym[k] = v
|
|
|
|
name = sym["name"]
|
|
|
|
syms[name] = sym
|
|
|
|
return syms
|