mirror of
https://github.com/michaelcmartin/Ophis.git
synced 2024-12-30 10:30:47 +00:00
A very, *very* poor-man's version of label<->address dump. Ugh!
This commit is contained in:
parent
83b8433b77
commit
c0bf2e98b7
@ -22,6 +22,7 @@ print_labels = False
|
||||
infiles = None
|
||||
outfile = None
|
||||
listfile = None
|
||||
mapfile = None
|
||||
|
||||
|
||||
def parse_args(raw_args):
|
||||
@ -31,7 +32,7 @@ def parse_args(raw_args):
|
||||
global warn_on_branch_extend
|
||||
global print_summary, print_loaded_files
|
||||
global print_pass, print_ir, print_labels
|
||||
global infiles, outfile, listfile
|
||||
global infiles, outfile, listfile, mapfile
|
||||
|
||||
parser = optparse.OptionParser(
|
||||
usage="Usage: %prog [options] srcfile [srcfile ...]",
|
||||
@ -41,6 +42,8 @@ def parse_args(raw_args):
|
||||
help="Output filename (default 'ophis.bin')")
|
||||
parser.add_option("-l", default=None, dest="listfile",
|
||||
help="Listing filename (not created by default)")
|
||||
parser.add_option("-m", default=None, dest="mapfile",
|
||||
help="Label-address map filename (not created by default)")
|
||||
|
||||
ingrp = optparse.OptionGroup(parser, "Input options")
|
||||
ingrp.add_option("-u", "--undoc", action="store_true", default=False,
|
||||
@ -83,6 +86,7 @@ def parse_args(raw_args):
|
||||
infiles = args
|
||||
outfile = options.outfile
|
||||
listfile = options.listfile
|
||||
mapfile = options.mapfile
|
||||
enable_branch_extend = options.enable_branch_extend
|
||||
enable_undoc_ops = options.undoc
|
||||
enable_65c02_exts = options.c02
|
||||
|
@ -88,3 +88,8 @@ class Environment(object):
|
||||
if len(self.stack) == 1:
|
||||
Err.log("Unmatched .scend")
|
||||
self.stack.pop(0)
|
||||
|
||||
def dump_mapfile(self, f):
|
||||
for d in self.dicts:
|
||||
for k in d:
|
||||
f.write("{0:<30} ${1:04X}\n".format(k, d[k]))
|
||||
|
@ -755,8 +755,16 @@ class Assembler(Pass):
|
||||
else:
|
||||
self.listing = Listing.NullLister()
|
||||
|
||||
def go(self, node, env):
|
||||
# record env, as we need it in postPass
|
||||
self.env = env
|
||||
super(Assembler, self).go(node, env)
|
||||
|
||||
def postPass(self):
|
||||
self.listing.dump()
|
||||
if Cmd.mapfile is not None:
|
||||
with open(Cmd.mapfile, 'w') as f:
|
||||
self.env.dump_mapfile(f)
|
||||
if Cmd.print_summary and Err.count == 0:
|
||||
print>>sys.stderr, "Assembly complete: %s bytes output " \
|
||||
"(%s code, %s data, %s filler)" \
|
||||
|
Loading…
Reference in New Issue
Block a user